contrib/release: restore original branch in dry-run mode

In dry-run mode, reset the branch to the state where it was before.

Also, in real mode delete the temporary "release-branch" branch on
success.
This commit is contained in:
Thomas Haller 2020-10-05 18:14:50 +02:00
parent a74cb152f2
commit 5e83bac5aa
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -207,6 +207,7 @@ TMP="$(LANG=C git clean -ndx)" || die "git clean -ndx failed"
test -z "$TMP" || die "git working directory is not clean? (git clean -ndx)"
CUR_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
CUR_HEAD="$(git rev-parse HEAD)"
TMP_BRANCH=release-branch
if [ "$CUR_BRANCH" = master ]; then
@ -476,7 +477,12 @@ for r in "${RELEASE_FILES[@]}"; do
do_command ssh master.gnome.org ftpadmin install --unattended "$r" || die "ftpadmin install failed"
done
CLEANUP_CHECKOUT_BRANCH=
if [ "$DRY_RUN" = 0 ]; then
CLEANUP_REFS=()
CLEANUP_CHECKOUT_BRANCH=
git branch -D "$TMP_BRANCH"
else
H="$(git rev-parse "$CUR_BRANCH")"
git checkout -B "$CUR_BRANCH" "$CUR_HEAD" || die "cannot reset $CUR_BRANCH to $CUR_HEAD"
echo "delete reference. Restore with $(echo_color 36 -n git checkout -B "\"$CUR_BRANCH\"" "$H")"
fi