summary refs log tree commit diff
path: root/jenkins/clone.sh
blob: f56d076ea9a9988b8c9c8ce1c0d2a0b53883fdfb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#! /bin/bash

NAME=$1
PROJECT=$2
BASE=".$NAME-base"

# update our clone
if [ ! -d .$NAME-base ]; then
  git clone $PROJECT $BASE --mirror
else
  (cd $BASE; git fetch -p)
fi

rm -rf $NAME
git clone $BASE $NAME --shared

: ${GIT_BRANCH:="origin/$(git rev-parse --abbrev-ref HEAD)"}
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 .