summaryrefslogtreecommitdiff
path: root/jenkins-helpers.sh
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2018-05-24 17:16:10 +0000
committerMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2018-05-24 17:16:10 +0000
commit6064f34d17a602c22d459731cafa2fc51e3f2982 (patch)
tree9729c099281605ced85036926e19f9debd364dcb /jenkins-helpers.sh
parent9f1aa0bc554f1ec64925f81a495e56324692efa1 (diff)
jenkins-helpers.sh: Make git_rev_parse handle SHA1^ references
... by switching to "git rev-parse". Change-Id: I1309177ab379a163b8d8117581e7c4ee8d7dae28
Diffstat (limited to 'jenkins-helpers.sh')
-rw-r--r--jenkins-helpers.sh17
1 files changed, 8 insertions, 9 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh
index 1b7f8daf..3ef69ad8 100644
--- a/jenkins-helpers.sh
+++ b/jenkins-helpers.sh
@@ -207,21 +207,20 @@ git_rev_parse ()
(
cd "$dir"
- # Resolve from URL.
- local url
- url=$(git remote get-url "$remote")
-
# Convert git branch/tag names into SHA1
local sha1 try_ref
case "$ref" in
"refs/"*) try_ref="$ref";;
- *) try_ref="refs/heads/$ref" ;;
+ *) try_ref="refs/remotes/$remote/$ref" ;;
esac
- sha1=$(git ls-remote "$url" "$try_ref" | cut -f 1)
+ sha1=$(git rev-parse --short "$try_ref")
if [ x"$sha1" = x"" ]; then
- # If "git ls-remote" can't resolve $ref, then assume it is
- # already SHA1.
- sha1="$ref"
+ # Assume that $ref is already a SHA1
+ sha1=$(git rev-parse --short "$ref")
+ if [ x"$sha1" = x"" ]; then
+ echo "ERROR: Cannot parse $ref in repo $dir" >&2
+ exit 1
+ fi
fi
echo "$sha1"
)