forked from dyne/zenpub-client
-
Notifications
You must be signed in to change notification settings - Fork 5
/
cpub-merge-from-branch.sh
executable file
·41 lines (34 loc) · 1.46 KB
/
cpub-merge-from-branch.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
CUR_BRANCH=$(git rev-parse --abbrev-ref HEAD)
FROM_BRANCH=flavour/commonspub
echo "This script helps merge updates into the current branch (${CUR_BRANCH}) from another branch, while preserving local customisations"
echo "What branch do you want to merge from? Press 'd' and enter if you want to use the default (${FROM_BRANCH}), otherwise enter the branch name:"
read answer
if echo "$answer" | grep -iq "^d" ; then
echo "Ok..."
else
FROM_BRANCH=$answer
fi
echo "Updating ${FROM_BRANCH} branch from origin"
git checkout ${FROM_BRANCH}
git pull
echo "Going back to the target ${CUR_BRANCH} branch"
git checkout ${CUR_BRANCH}
echo "Merging, without commiting yet"
git merge --no-ff --no-commit ${FROM_BRANCH}
echo "Restoring files which we don't want overwritten (add any core files that should be different in each flavour to the below line in the script)"
for file in README.md .env.example .env.secrets.example docker-compose.yml docker-compose.pi.yml .gitlab-ci.yml public/index.html src/mn-constants.tsx
do
git reset HEAD ${file}
git checkout -- ${file}
done
echo "Please check if everything looks good (including resolving any merge conflicts) before continuing. Press 'c' to merge and push the changes, or just enter to abort."
read answer
if echo "$answer" | grep -iq "^c" ; then
echo "Merging and pushing..."
git commit -m "merged branch ${FROM_BRANCH} to ${CUR_BRANCH}"
git push
else
echo "Aborting the merge."
git merge --abort
exit 1
fi