Improve tools/build-auto-update.sh when working on detached HEAD

This commit is contained in:
catbref 2020-10-28 09:08:16 +00:00
parent f3b8258067
commit 9c18a33d7f

View File

@ -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}