-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgit-lava-erupt
56 lines (45 loc) · 1.25 KB
/
git-lava-erupt
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
#!/bin/bash
cmd_default() {
local DELETE=0
local FLAGS
while getopts dDf OPTION
do
case $OPTION in
d)
DELETE=1
;;
D)
DELETE=2
;;
f)
FLAGS="-f"
;;
esac
done
# Reset $@
shift `echo $OPTIND-1 | bc`
local BRANCHNAME=$(current_branch)
local MERGETARGET=${1:-$(local_merge_target $BRANCHNAME || echo master)}
local ORIGIN=$(branch_origin $MERGETARGET || echo origin)
require_local_branch $MERGETARGET
require_remote_branch "$ORIGIN/$MERGETARGET"
git lava converge $FLAGS $MERGETARGET && \
git push $ORIGIN $MERGETARGET
if [ $DELETE -eq 1 ] && [ $? -eq 0 ]; then
git branch -d $BRANCHNAME
elif [ $DELETE -eq 2 ] && [ $? -eq 0 ] && [ "$MERGETARGET" != "master" ]; then
git checkout master
git branch -d $BRANCHNAME $MERGETARGET
else
git checkout $BRANCHNAME
fi
}
cmd_help() {
echo "git lava erupt [-dDf] [<base>]"
echo
echo "Converges the current branch into the base branch, then pushes the base"
echo "branch. By default, if there is more than one commit, a merge commit"
echo "will be created. To always fast-forward, use the optional -f flag."
echo "The optional -d flag will delete the current branch when done. The"
echo "optional -D flag will delete both the current branch and the merge target."
}