checkout.sh (1144B)
1 #!/bin/sh 2 set -e 3 4 # Workaround old docker images with incorrect $HOME 5 # check https://github.com/docker/docker/issues/2968 for details 6 if [ "${HOME}" = "/" ] 7 then 8 export HOME=$(getent passwd $(id -un) | cut -d: -f6) 9 fi 10 11 replace='https://github.com/' 12 to_replace='git@github.com:' 13 NEW_CIRCLE_REPOSITORY_URL="${CIRCLE_REPOSITORY_URL/$to_replace/$replace}" 14 15 if [ -e /home/user/work/src/github.com/Nordgedanken/Morpheusv2/.git ] 16 then 17 cd /home/user/work/src/github.com/Nordgedanken/Morpheusv2/ 18 git remote set-url origin "$NEW_CIRCLE_REPOSITORY_URL" || true 19 else 20 mkdir -p /home/user/work/src/github.com/Nordgedanken/Morpheusv2/ 21 cd /home/user/work/src/github.com/Nordgedanken/Morpheusv2/ 22 git clone "$NEW_CIRCLE_REPOSITORY_URL" . 23 fi 24 25 if [ -n "$CIRCLE_TAG" ] 26 then 27 git fetch --force origin "refs/tags/${CIRCLE_TAG}" 28 else 29 git fetch --force origin "${CIRCLE_BRANCH}:remotes/origin/${CIRCLE_BRANCH}" 30 fi 31 32 33 if [ -n "$CIRCLE_TAG" ] 34 then 35 git reset --hard "$CIRCLE_SHA1" 36 git checkout -q "$CIRCLE_TAG" 37 elif [ -n "$CIRCLE_BRANCH" ] 38 then 39 git reset --hard "$CIRCLE_SHA1" 40 git checkout -q -B "$CIRCLE_BRANCH" 41 fi 42 43 git reset --hard "$CIRCLE_SHA1"