-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupstream_merge_tool.sh
executable file
·69 lines (62 loc) · 2.57 KB
/
upstream_merge_tool.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
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
echo "Moony's upstream merge workflow tool."
echo "This tool can be stopped at any time, i.e. to finish a merge or resolve conflicts. Simply rerun the tool after having resolved the merge with normal git CLI."
echo "Pay attention to any output from git! DO NOT RUN THIS ON A WORKING TREE WITH UNCOMMITTED FILES OF ANY KIND."
read -p "Enter the branch you're syncing toward (typically upstream/master or similar): " target
refs=$(git log --reverse --format=format:%H HEAD.."$target")
git config user.email "[email protected]"
git config user.name "melano"
options=("Cherry-pick" "Merge" "Skip")
g
for unmerged in $refs; do
summary=$(git show --format=format:%s "$unmerged")
if [ "$summary" == "automatic changelog update" ]; then
echo "Deliberately skipping changelog bot commit $unmerged."
echo "== GIT (CONFLICTS ARE OKAY) =="
git merge --no-ff --no-commit --no-verify "$unmerged"
# DELIBERATELY IGNORE merge conflict markers. We're just going to undo the commit!
git add .
git commit -m "squash! Merge tool skipping '$unmerged'"
newhead=$(git log -n 1 --format=format:%H)
git reset HEAD~ --hard
git reset "$newhead" --soft
git commit --amend --no-edit
echo "== DONE =="
continue
fi
git show --format=full --summary "$unmerged"
PS3="Commit action? "
select option in "${options[@]}"; do
case $REPLY in
1)
echo "== GIT =="
git cherry-pick "$unmerged"
echo "== DONE =="
break
;;
2)
echo "== GIT =="
git merge --no-ff -m "squash! Merge tool integrating '$unmerged'" "$unmerged"
echo "== DONE =="
break
;;
3)
echo "Skipping $unmerged"
echo "== GIT (CONFLICTS ARE OKAY) =="
git merge --no-ff --no-commit --no-verify "$unmerged"
# DELIBERATELY IGNORE merge conflict markers. We're just going to undo the commit!
git add .
git commit -m "squash! Merge tool skipping '$unmerged'"
newhead=$(git log -n 1 --format=format:%H)
git reset HEAD~ --hard
git reset "$newhead" --soft
git commit --amend --no-edit
echo "== DONE =="
break
;;
*)
echo "Invalid option, please select a valid option."
;;
esac
done
done