summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2021-07-26 10:29:25 +0000
committerMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2021-07-26 10:29:25 +0000
commitfb7852bee8f941240b046236188fbebc759cf2a5 (patch)
treec8168711e039314f9823b46c00e773f8d769a976
parent268e16e2ba1eaef8e211d6a0728c92f8cbde14c0 (diff)
round-robin.sh (clone_repo): Fix checkout of branches
Change-Id: I750be137aa978be5334bdce258d674804650c6da
-rw-r--r--jenkins-helpers.sh29
-rw-r--r--round-robin.sh3
2 files changed, 24 insertions, 8 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh
index 7feb3edf..771ace4b 100644
--- a/jenkins-helpers.sh
+++ b/jenkins-helpers.sh
@@ -514,6 +514,28 @@ clone_or_update_repo_no_checkout ()
)
}
+# Checkout branch/ref/SHA1 in a git repo
+# $1 -- repo directory
+# $2 -- ref to checkout
+# $3 -- name of the git remote
+git_checkout ()
+{
+ (
+ set -euf -o pipefail
+
+ local dir="$1"
+ local ref="$2"
+ local remote="$3"
+
+ git_clean "$dir"
+ # Convert git branch/tag names into SHA1
+ local sha1
+ sha1=$(git_rev_parse "$dir" "$ref" "$remote")
+ # Checkout
+ git -C "$dir" checkout --detach "$sha1"
+ )
+}
+
# Clone or update a git repo
# $1 -- repo directory
# $2 -- ref to checkout
@@ -536,12 +558,7 @@ clone_or_update_repo ()
clone_or_update_repo_no_checkout "$dir" "$url" "$reference" \
"$single_branch" "$remote"
- git_clean "$dir"
- # Convert git branch/tag names into SHA1
- local sha1
- sha1=$(git_rev_parse "$dir" "$ref" "$remote")
- # Checkout
- git -C "$dir" checkout --detach "$sha1"
+ git_checkout "$dir" "$ref" "$remote"
)
}
diff --git a/round-robin.sh b/round-robin.sh
index feeafae3..5015c716 100644
--- a/round-robin.sh
+++ b/round-robin.sh
@@ -165,8 +165,7 @@ clone_repo ()
# Allow manifest override
branch="${rr[${project}_rev]-$branch}"
-
- git -C $project checkout --detach "$branch"
+ git_checkout "$project" "$branch" origin
local cur_rev
cur_rev=$(git -C $project rev-parse HEAD)