diff options
author | Mark Haines <mjark@negativecurvature.net> | 2016-08-04 12:31:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-04 12:31:55 +0100 |
commit | 1fc50712d6729c85680e8ebe1c8612c304217c47 (patch) | |
tree | 5e8c1621d21ac2cc27d726b8ea38084919341b7f /jenkins | |
parent | Merge pull request #978 from matrix-org/rav/device_name_in_e2e_devices (diff) | |
download | synapse-1fc50712d6729c85680e8ebe1c8612c304217c47.tar.xz |
Factor out more common code from the jenkins scripts (#980)
* Factor out more common code from the jenkins scripts * Fix install_and_run path * Poke jenkins * Poke jenkins
Diffstat (limited to 'jenkins')
-rwxr-xr-x | jenkins/clone.sh | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/jenkins/clone.sh b/jenkins/clone.sh index f56d076ea9..ab30ac7782 100755 --- a/jenkins/clone.sh +++ b/jenkins/clone.sh @@ -1,24 +1,44 @@ #! /bin/bash +# This clones a project from github into a named subdirectory +# If the project has a branch with the same name as this branch +# then it will checkout that branch after cloning. +# Otherwise it will checkout "origin/develop." +# The first argument is the name of the directory to checkout +# the branch into. +# The second argument is the URL of the remote repository to checkout. +# Usually something like https://github.com/matrix-org/sytest.git + +set -eux + NAME=$1 PROJECT=$2 BASE=".$NAME-base" -# update our clone -if [ ! -d .$NAME-base ]; then - git clone $PROJECT $BASE --mirror +# Update our mirror. +if [ ! -d ".$NAME-base" ]; then + # Create a local mirror of the source repository. + # This saves us from having to download the entire repository + # when this script is next run. + git clone "$PROJECT" "$BASE" --mirror else - (cd $BASE; git fetch -p) + # Fetch any updates from the source repository. + (cd "$BASE"; git fetch -p) fi -rm -rf $NAME -git clone $BASE $NAME --shared +# Remove the existing repository so that we have a clean copy +rm -rf "$NAME" +# Cloning with --shared means that we will share portions of the +# .git directory with our local mirror. +git clone "$BASE" "$NAME" --shared +# Jenkins may have supplied us with the name of the branch in the +# environment. Otherwise we will have to guess based on the current +# commit. : ${GIT_BRANCH:="origin/$(git rev-parse --abbrev-ref HEAD)"} -cd $NAME +cd "$NAME" # check out the relevant branch git checkout "${GIT_BRANCH}" || ( echo >&2 "No ref ${GIT_BRANCH} found, falling back to develop" git checkout "origin/develop" ) -git clean -df . |