1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

chore(merge-script): add check for number and a useful failure message

Message appears only if merge was unsuccessful and makes deleting
as quick as copypasting.

Check makes sure that supplied argument is actually an number, which
helps avoid waiting for git to eror out on "no remote branch".

Additionally, renamed `original` upstream to `upstream`, according to
@sudden6's suggestion.
This commit is contained in:
Zetok Zalbavar 2016-03-29 01:03:17 +01:00
parent 791d871737
commit b9abea636e
No known key found for this signature in database
GPG Key ID: C953D3880212068A

View File

@ -41,13 +41,17 @@ $2
fi fi
# FIXME: ↓ # check if supplied var is a number; if not exit
#[[ ${PR} =~ "^[:digit:]+$" ]] || echo "Not a PR number!" && exit 1 if [[ ! "${PR}" =~ ^[[:digit:]]+$ ]]
then
echo "Not a PR number!" && \
exit 1
fi
# list remotes, and if there's no tux3 one, add it # list remotes, and if there's no tux3 one, add it
if ! git remote | grep original > /dev/null if ! git remote | grep upstream > /dev/null
then then
git remote add original git@github.com:tux3/qTox.git git remote add upstream git@github.com:tux3/qTox.git
fi fi
# print the message only if the merge was successful # print the message only if the merge was successful
@ -58,20 +62,30 @@ after_merge_msg() {
echo "git diff master..merge$PR" echo "git diff master..merge$PR"
echo "" echo ""
echo "To push that to master on github:" echo "To push that to master on github:"
echo "git checkout master && git merge --ff merge$PR && git push original master" echo "git checkout master && git merge --ff merge$PR && git push upstream master"
echo "" echo ""
echo "After pushing to master, delete branches:" echo "After pushing to master, delete branches:"
echo "" echo ""
echo "git branch -d {merge,}$PR" echo "git branch -d {merge,}$PR"
} }
# print the message only if some merge step failed
after_merge_failure_msg() {
echo ""
echo "Merge failed."
echo ""
echo "You may want to remove not merged branches, if they exist:"
echo ""
echo "git checkout master && git branch -D {merge,}$PR"
}
git fetch original && \
git fetch upstream && \
git checkout master && \ git checkout master && \
git rebase original/master master && \ git rebase upstream/master master && \
git fetch original pull/$PR/head:$PR && \ git fetch upstream pull/$PR/head:$PR && \
git checkout master -b merge$PR && \ git checkout master -b merge$PR && \
git merge --no-ff -S $PR -m "Merge pull request #$PR git merge --no-ff -S $PR -m "Merge pull request #$PR
$OPT_MSG $OPT_MSG
$(git shortlog master..$PR)" && \ $(git shortlog master..$PR)" && \
after_merge_msg after_merge_msg || after_merge_failure_msg