-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathcommit.sh
66 lines (53 loc) · 2.33 KB
/
commit.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
function printUsageAndExit() {
echo "----------------------------------------------------------------------------------------------------"
echo $1
echo "----------------------------------------------------------------------------------------------------"
echo "用法:下面命令之一"
echo " 提交一个 [新增]: sh tools/commit.sh new 本次提交的简要说明(必选),解决了 @123和@456(可选)"
echo " 提交一个 [故障]: sh tools/commit.sh fix 本次提交的简要说明(必选),解决了 @123和@456(可选)"
echo " 提交一个 [优化]: sh tools/commit.sh opt 本次提交的简要说明(必选),解决了 @123和@456(可选)"
echo " 提交一个 [其他]: sh tools/commit.sh ot 本次提交的简要说明(必选),解决了 @123和@456(可选)"
echo " "
echo " 提交一个 [破坏性修改]:sh tools/commit.sh bc 本次提交的简要说明(必选),解决了 @123和@456(可选)"
echo " "
echo " 将代码推送给服务器: sh tools/commit.sh push"
echo "----------------------------------------------------------------------------------------------------"
echo "其他:通过自然语言让当前commit与issue关联的方法"
echo " 例子1: 解决@123、@456"
echo " 例子2: 解决了@123、@456"
echo " 例子3: 关联@123、@456"
echo " 例子4: 关联@123,解决了@456"
exit 1
}
command=$1
if [[ "$command" != "new" && "$command" != "fix" && "$command" != "opt" && \
"$command" != "ot" && "$command" != "bc" && "$command" != "push" ]];then
printUsageAndExit '未支持的指令 ['$command'],必须是 new / fix / opt / bc / push 之一'
fi
shift 1
if [[ "$command" == "push" ]]; then
git push $*
exit 0
fi
message=$*
if [[ "$message" == "" ]]; then
printUsageAndExit '提交的信息不能为空!'
fi
if [[ "$command" == "new" ]]; then
message="[新增] $message"
fi
if [[ "$command" == "fix" ]]; then
message="[故障] $message"
fi
if [[ "$command" == "opt" ]]; then
message="[优化] $message"
fi
if [[ "$command" == "ot" ]]; then
message="[其他] $message"
fi
if [[ "$command" == "bc" ]]; then
message="[破坏性修改] $message"
fi
echo "正在提交:$message ..."
git commit -m "$message"