-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmob-session.sh
More file actions
executable file
·100 lines (89 loc) · 2.13 KB
/
mob-session.sh
File metadata and controls
executable file
·100 lines (89 loc) · 2.13 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
set -e
start() {
git fetch origin master
git checkout master
git merge origin/master --ff-only
git checkout -b $BRANCHNAME
git push --set-upstream origin $BRANCHNAME --no-verify
echo "session $BRANCHNAME started"
}
pass() {
git fetch origin master
git add -N .
git add -p
git commit -m "WIP - Pass to next" --allow-empty
git push origin $BRANCHNAME --no-verify
git checkout master
git branch -D $BRANCHNAME
echo "session $BRANCHNAME passed"
}
receive() {
git checkout master
if git show-ref --quiet refs/heads/$BRANCHNAME; then
echo "branch $BRANCHNAME already exists and will be deleted"
git branch -D $BRANCHNAME
else
echo "branch $BRANCHNAME does not exist"
fi
git fetch origin $BRANCHNAME
git checkout --track origin/$BRANCHNAME
echo "session $BRANCHNAME received"
}
finish() {
git add -N .
git add -p
git commit -m "WIP - Finish" --allow-empty
git fetch origin master
git checkout master
git merge origin/master --ff-only
git merge --squash --ff $BRANCHNAME
git branch -D $BRANCHNAME
git push origin --delete $BRANCHNAME --no-verify
echo "session $BRANCHNAME finished"
}
usage() {
echo "Usage:"
echo ""
echo "mob-session.sh <option> [branchname]"
echo ""
echo "Where <option> is one of:"
echo "--start : To start a mob session"
echo "--receive : To receive the handover branch"
echo "--pass : To push the handover branch"
echo "--finish : To finish the mob session"
echo ""
echo "Where [branch] can optionally be specified to use your own handover branch name. Default handover branch name is mob-session"
}
if [[ $# -gt 2 ]]; then
usage
exit 2
fi
while test $# -gt 0
do
case "$1" in
--start) COMMAND=start
;;
--pass) COMMAND=pass
;;
--receive) COMMAND=receive
;;
--finish) COMMAND=finish
;;
--*) COMMAND=usage
;;
*) BRANCNAMEARG=$1
;;
esac
shift
done
if [[ -z "$COMMAND" ]]; then
usage
exit 2
fi
if [[ -z $BRANCNAMEARG ]]; then
BRANCHNAME="mob-session"
else
BRANCHNAME=$BRANCNAMEARG
fi
"$COMMAND"