summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtcwg-release.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/tcwg-release.sh b/tcwg-release.sh
index ed8f756..833aaed 100755
--- a/tcwg-release.sh
+++ b/tcwg-release.sh
@@ -205,6 +205,12 @@ clean() {
# there.
popd &>/dev/null
+ # Return the tree to the starting branch if it's not already there. We
+ # can't be in one of the working branches if we want to delete it.
+ if [ "${save_branch+:set}" = "set" ]; then
+ git checkout ${save_branch} 1>/dev/null
+ fi
+
ask "May I remove ${REL_DIR}/git [N/y] ?" user_ok
if [ "$user_ok" = "y" ]; then
if [ -d "$REL_DIR/git" ]; then
@@ -590,6 +596,10 @@ if [ "x${track}" = "x" ]; then
BRANCH=$track
fi
+# Keep track of the branch we start from because we'll want to return there at
+# the end or if we have to cleanup prematurely.
+save_branch="$(git rev-parse --abbrev-ref HEAD)"
+
# Test to make sure the branch or tag exists
git rev-parse --abbrev-ref $track &>/dev/null || die "${TAG:+Tag }${BRANCH:+Branch }\"$track\" doesn't exist."