From 9c18a33d7f3b876d5bdb3c9a368d2765f79dd680 Mon Sep 17 00:00:00 2001 From: catbref Date: Wed, 28 Oct 2020 09:08:16 +0000 Subject: [PATCH] Improve tools/build-auto-update.sh when working on detached HEAD --- tools/build-auto-update.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/build-auto-update.sh b/tools/build-auto-update.sh index db651a39..4124f1e2 100755 --- a/tools/build-auto-update.sh +++ b/tools/build-auto-update.sh @@ -13,7 +13,7 @@ fi cd ${git_dir} # Check we are in 'master' branch -branch_name=$( git symbolic-ref -q HEAD ) +branch_name=$( git symbolic-ref -q HEAD || echo ) branch_name=${branch_name##refs/heads/} echo "Current git branch: ${branch_name}" if [ "${branch_name}" != "master" ]; then @@ -78,5 +78,7 @@ git add ${project}.update git commit --message "XORed, auto-update JAR based on commit ${short_hash}" git push --set-upstream origin --force-with-lease ${update_branch} +branch_name=${branch_name-master} + echo "Changing back to '${branch_name}' branch" git checkout --force ${branch_name}