/
git-shell.sh
executable file
·54 lines (47 loc) · 987 Bytes
/
git-shell.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
#! /bin/bash
commit_message="update";
if test -z "$1"
then
read dataOne
else
dataOne=$1
fi
case ${dataOne} in
1)
exit
;;
2)
tag="1.0.1"
tag_list=$(git tag --sort version:refname)
OLD_IFS="$IFS"
IFS=" "
arr=($tag_list)
IFS="$OLD_IFS"
tag_length=0;
for s in ${arr[@]}
do
tag_length=`expr ${tag_length} + 1`
done
# 判断是否有打过tag
hundreds=0 # 百位数字
if test $[tag_length] -gt 0
then
num=${tag_length}
if [ ${num} -ge 1000 ]
then
hundreds=`expr ${num} / 1000`
fi
num=`expr ${num} % 1000 + 1`
tag="1.${hundreds}.${num}"
fi
echo "push tag: ${tag}"
git tag ${tag} && git push origin ${tag}
exit
;;
*)
commit_message=${dataOne};
;;
esac
branch_list=$(git branch | grep '*')
current_branch=${branch_list:2}
git status && git add -A && git commit -m "${commit_message}" && git push origin ${current_branch}