[MERGED] osmo-gsm-tester[master]: jenkins-build-common.sh: fix being stuck on branch

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Jun 23 01:59:51 UTC 2017


Neels Hofmeyr has submitted this change and it was merged.

Change subject: jenkins-build-common.sh: fix being stuck on branch
......................................................................


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
---
M contrib/jenkins-build-common.sh
1 file changed, 3 insertions(+), 1 deletion(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Jenkins Builder: Verified



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 @@
   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
     branch="origin/$branch"
   fi
 
+  git branch -D build_branch || true
+  git checkout -b build_branch "$branch"
   git reset --hard "$branch"
 
   git rev-parse HEAD

-- 
To view, visit https://gerrit.osmocom.org/3020
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2e610b357f8559c6b6ffb544eb0a952f04dd9f70
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list