diff options
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-06-23 03:52:26 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-06-23 03:52:26 +0200
commit851802b927ccfcb061a2774fdc5de12141426b5c (patch)
parentde79cb155d2a59ba446ee4ecd7b653dad40dccad (diff)
jenkins-build-common.sh: fix being stuck on branch
It's hard to allow both branch names and git hashes. For a branch, we want to prepend 'origin' to use the upstream branch. For a git hash, we don't. We so far prepend 'origin/' if the current branch name doesn't resolve, but that's not enough. If a local 'master' branch exists, we would stay on that branch instead of origin/master. Rather, prepend 'origin/' if 'origin/$branch' exists. Git hashes should not exist as 'origin/123abc...' and used as-is, where branches from origin should be updated to upstream by prepending 'origin/'. Also create a local branch to build. Always force-remove the branch and re-create from the origin/name or git hash. Keep the reset --hard for paranoia. Change-Id: I2e610b357f8559c6b6ffb544eb0a952f04dd9f70
1 files changed, 3 insertions, 1 deletions
diff --git a/contrib/jenkins-build-common.sh b/contrib/jenkins-build-common.sh
index 921434d..63e0ba8 100644
--- a/contrib/jenkins-build-common.sh
+++ b/contrib/jenkins-build-common.sh
@@ -81,10 +81,12 @@ have_repo() {
git fetch origin
# Figure out whether we need to prepend origin/ to find branches in upstream
- if ! git rev-parse "$branch"; then
+ if git rev-parse "origin/$branch"; then
+ git branch -D build_branch || true
+ git checkout -b build_branch "$branch"
git reset --hard "$branch"
git rev-parse HEAD