On release fail, checkout whatever previous branch it was, not hardcoded "master"

This commit is contained in:
Ximin Luo 2018-07-05 19:56:49 -07:00
parent bb23d707cf
commit 32c1fb5be1

View File

@ -10,7 +10,8 @@ abort 1 "Please git-add your changes to $PKGDIR_REL before running"
RELBRANCH="pending-$PKGNAME"
git fetch origin --prune
case "$(git rev-parse --abbrev-ref HEAD)" in
PREVBRANCH="$(git rev-parse --abbrev-ref HEAD)"
case "$PREVBRANCH" in
pending-$PKGNAME) true;;
pending-*) abort 1 "You are on a pending-release branch for a package other than $PKGNAME, $0 can only be run on another branch, like master";;
*) if git rev-parse -q --verify "refs/heads/$RELBRANCH" >/dev/null || \
@ -22,8 +23,8 @@ pending-*) abort 1 "You are on a pending-release branch for a package other than
esac
if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then
git checkout master
abort 0 "Package already released. If that was a mistake then checkout another branch, delete this one ($RELBRANCH), and re-run this script ($0 $*)"
git checkout "$PREVBRANCH"
abort 0 "Package already released. If that was a mistake then run \`git branch -D $RELBRANCH\`, and re-run this script ($0 $*)"
fi
( cd "$PKGDIR"