-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgit-lava-converge
50 lines (36 loc) · 1.12 KB
/
git-lava-converge
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
#!/bin/bash
cmd_default() {
local FLAGS
local FF=0
while getopts f OPTION
do
case $OPTION in
f) FF=1;;
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)
run_hook "pre-lava-converge"
require_local_branch $MERGETARGET
require_remote_branch "$ORIGIN/$MERGETARGET"
echo -e "Merging with branch '$MERGETARGET'"
if [ $(git log "$ORIGIN/$MERGETARGET..$BRANCHNAME" --oneline | wc -l) -gt 1 ] && [ $FF -eq 0 ]; then
FLAGS="--no-ff"
echo -e "(Creating a merge commit)"
fi
git lava flow $MERGETARGET && \
git checkout $MERGETARGET && \
git merge $ORIGIN/$MERGETARGET && \
git merge $FLAGS $BRANCHNAME
}
cmd_help() {
echo "git lava converge [-f] [<base>]"
echo
echo "Update the current branch and merge it into the base branch. Defaults"
echo "to the base branch saved by git lava diverge or master. By default,"
echo "if there is more than 1 commit, a merge commit will be created."
echo "To always fast-forward, use the optional -f flag."
}