forked from wkh237/react-native-fetch-blob-dev
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathils.sh
59 lines (48 loc) · 1.3 KB
/
ils.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
ISSUE_NUM=$1
ACTION=$2
if [ "$#" = 0 ]; then
git branch | grep issue
exit 0
fi
if [ $1 = "help" ]; then
echo " [issue number]\tnv\tchange branch name to issue-XX-needs-verify\n"\
"[issue number]\twip\tchange branch name to issue-XX-wip\n"\
"[issue number]\tmg\tchange branch name to issue-XX-merged\n"\
"[issue number]\trm\tremove branch\n"\
"[issue number]\tadd\tadd branch issue-XX\n"
exit 0
fi
if [ -z $ACTION ]; then
git branch | grep $ISSUE_NUM
exit 0
fi
if [ $ACTION = "add" ]; then
git branch "issue-${ISSUE_NUM}"
echo "Created branch ${TARGET_BRANCH_NAME}"
exit 0
fi
if [ $ACTION = "go" ]; then
EXISTED=$(git branch | grep $ISSUE_NUM)
if [ "$EXISTED" == "" ]; then
echo "branch issue-${ISSUE_NUM} not exists, checkout -b"
git checkout -b "issue-${ISSUE_NUM}"
else
git checkout $(git branch | grep $ISSUE_NUM)
fi
exit 0
fi
TARGET_BRANCH_NAME="$(git branch | grep $1)"
if [ $ACTION = "rm" ]; then
git branch -D $TARGET_BRANCH_NAME
exit 0
fi
if [ $ACTION = "nv" ]; then
NEW_NAME="issue-${ISSUE_NUM}-needs-verify"
elif [ $ACTION = "wip" ]; then
NEW_NAME="issue-${ISSUE_NUM}-wip"
elif [ $ACTION = "mg" ]; then
NEW_NAME="issue-${ISSUE_NUM}-merged"
fi
echo "Rename ${TARGET_BRANCH_NAME} to ${NEW_NAME}"
git branch -m ${TARGET_BRANCH_NAME} ${NEW_NAME}
git branch | grep issue