-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommit
67 lines (60 loc) · 1.05 KB
/
commit
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
66
67
#!/bin/bash
sign=true
push=true
message="some changes"
for i in $*
do
index=$[index+1]
if [ $i = "-ns" ]
then
sign=false
fi
if [ $i = "-np" ]
then
push=false
fi
if [ $i = "-h" ]
then
echo "Usage: commit [-ns] [-np] [-h] [-m] [message]"
echo " -ns: do not sign the commit"
echo " -np: do not push the commit"
echo " -h: print this help"
echo " -m: commit message"
echo " message: commit message"
exit 0
fi
if [ $i = "-v" ]
then
echo "Version: 0.1"
fi
if [ $i = "-a" ]
then
echo "Author: ZhouHaoyu"
fi
if [ $i = "-m" ]
then
message=''
_index=`expr $index + 1`
# -m后所有的参数都是commit message,并且保留空格
for j in ${@:$_index}
do
message=$message$j" "
done
fi
done
git add .
echo "git adding..."
if [ $sign = true ]
then
echo "your commit will be signed"
git commit -s -m "$message"
else
git commit -m "$message"
fi
if [ $push = true ]
then
echo "your commit will be pushed"
git push
else
echo "your commit will not be pushed"
fi