generate-git-snapshot: do not fail with branch specifier being a commit ID

When building with the branch specifier set to a commit ID,
Jenkins detaches the HEAD and sets GIT_BRANCH to detached.

The `git checkout -f ${GIT_BRANCH}` at the end of
generate-git-snapshot fails because a branch named "detached"
does not exist.

Closes #17 @ GH
Thanks: Jan Alexander Steffens <jan.steffens@gmail.com> for bugreport + patch
remotes/origin/debian/stretch
Michael Prokop 9 years ago
parent 59e1a99c79
commit 737e4e950a

@ -487,7 +487,11 @@ fi
# revert to original debian/changelog to avoid merge conflicts
git checkout -- $(readlink -f debian/changelog)
git checkout -f ${GIT_BRANCH} # switch back to previous "branch" before removing the tmp branch
# switch back to previous "branch" before removing the tmp branch
if ! git checkout -f "${GIT_BRANCH}"; then
# we were probably detached
git checkout -f "${GIT_COMMIT}"
fi
git branch -D "$random_branch"
# vim:foldmethod=marker ts=2 ft=sh ai expandtab sw=2

Loading…
Cancel
Save