From 5e83bac5aa9fd0088269780b2ad0ecbac2e94319 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 5 Oct 2020 18:14:50 +0200 Subject: [PATCH] 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. --- contrib/fedora/rpm/release.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/fedora/rpm/release.sh b/contrib/fedora/rpm/release.sh index e049ecbe8c..baec7665fd 100755 --- a/contrib/fedora/rpm/release.sh +++ b/contrib/fedora/rpm/release.sh @@ -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