Update `merge-pr.sh` script

This commit is contained in:
Pedro Pombeiro 2018-08-14 14:56:10 +02:00
parent cf2c211467
commit c925586e0e
No known key found for this signature in database
GPG Key ID: A65DEB11E4BBC647
1 changed files with 17 additions and 0 deletions

View File

@ -37,6 +37,22 @@ check_pr_prereq() {
fi fi
} }
check_sync() {
git fetch
if [ -n "$(git rev-list $BRANCH..$REMOTE/$BRANCH)" ]; then
warn "the local branch $BRANCH is behind $REMOTE/$BRANCH."
echo "Do you want to cancel or do you prefer to abandon your work and reset local $BRANCH to $REMOTE/$BRANCH ?"
echo "cancel/reset"
read response;
if [ "$response" = "reset" ]; then
git fetch $REMOTE
git reset --hard $REMOTE/$BRANCH
else
fatal "the local branch $BRANCH is behind $REMOTE/$BRANCH."
fi
fi
}
GH_URL_BASE="https://api.github.com" GH_URL_BASE="https://api.github.com"
get_pr_info() { get_pr_info() {
@ -133,6 +149,7 @@ EOF
fi fi
load_config load_config
check_pr_prereq check_pr_prereq
check_sync
get_pr_info "$@" get_pr_info "$@"
cleanup cleanup
fetch_pr fetch_pr