aboutsummaryrefslogtreecommitdiff
path: root/dev
diff options
context:
space:
mode:
authorThéo Zimmermann2019-02-18 15:32:42 +0100
committerThéo Zimmermann2019-02-18 15:33:10 +0100
commit7e03019c888161cb027dd76c3fa393d3d8f442e5 (patch)
tree59a4f2ef64c72f56ba53b6101ea1f78310ef9785 /dev
parent77b454e5ab8698f0d87bdf2eb32b48ab998ba590 (diff)
[ci] Resolve commit corresponding to branch when downloading tarball.
This ensures that the log will contain the commit hash that we tested. This reuses the method from the Windows build script (we have a number of common functions, it would be interesting to start a bash shared library file).
Diffstat (limited to 'dev')
-rw-r--r--dev/ci/ci-common.sh21
1 files changed, 12 insertions, 9 deletions
diff --git a/dev/ci/ci-common.sh b/dev/ci/ci-common.sh
index a5aa54144c..b4d2a9ca4e 100644
--- a/dev/ci/ci-common.sh
+++ b/dev/ci/ci-common.sh
@@ -62,27 +62,30 @@ git_download()
{
local PROJECT=$1
local DEST="$CI_BUILD_DIR/$PROJECT"
+ local GITURL_VAR="${PROJECT}_CI_GITURL"
+ local GITURL="${!GITURL_VAR}"
+ local REF_VAR="${PROJECT}_CI_REF"
+ local REF="${!REF_VAR}"
if [ -d "$DEST" ]; then
echo "Warning: download and unpacking of $PROJECT skipped because $DEST already exists."
elif [ "$FORCE_GIT" = "1" ] || [ "$CI" = "" ]; then
- local GITURL_VAR="${PROJECT}_CI_GITURL"
- local GITURL="${!GITURL_VAR}"
- local REF_VAR="${PROJECT}_CI_REF"
- local REF="${!REF_VAR}"
git clone "$GITURL" "$DEST"
cd "$DEST"
git checkout "$REF"
else # When possible, we download tarballs to reduce bandwidth and latency
local ARCHIVEURL_VAR="${PROJECT}_CI_ARCHIVEURL"
local ARCHIVEURL="${!ARCHIVEURL_VAR}"
- local REF_VAR="${PROJECT}_CI_REF"
- local REF="${!REF_VAR}"
mkdir -p "$DEST"
cd "$DEST"
- wget "$ARCHIVEURL/$REF.tar.gz"
- tar xvfz "$REF.tar.gz" --strip-components=1
- rm -f "$REF.tar.gz"
+ local COMMIT=$(git ls-remote "$GITURL" "refs/heads/$REF" | cut -f 1)
+ if [[ "$COMMIT" == "" ]]; then
+ # $REF must have been a tag or hash, not a branch
+ COMMIT="$REF"
+ fi
+ wget "$ARCHIVEURL/$COMMIT.tar.gz"
+ tar xvfz "$COMMIT.tar.gz" --strip-components=1
+ rm -f "$COMMIT.tar.gz"
fi
}