commit
73e5a1a74f
1 changed files with 22 additions and 11 deletions
33
stack.sh
33
stack.sh
|
@ -302,20 +302,31 @@ sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*`
|
|||
# be owned by the installation user, we create the directory and change the
|
||||
# ownership to the proper user.
|
||||
function git_clone {
|
||||
# if there is an existing checkout, move it out of the way
|
||||
if [[ "$RECLONE" == "yes" ]]; then
|
||||
# FIXME(ja): if we were smarter we could speed up RECLONE by
|
||||
# using the old git repo as the basis of our new clone...
|
||||
if [ -d $2 ]; then
|
||||
mv $2 /tmp/stack.`date +%s`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -d $2 ]; then
|
||||
git clone $1 $2
|
||||
GIT_REMOTE=$1
|
||||
GIT_DEST=$2
|
||||
GIT_BRANCH=$3
|
||||
|
||||
# do a full clone only if the directory doesn't exist
|
||||
if [ ! -d $GIT_DEST ]; then
|
||||
git clone $GIT_REMOTE $GIT_DEST
|
||||
cd $2
|
||||
# This checkout syntax works for both branches and tags
|
||||
git checkout $3
|
||||
git checkout $GIT_BRANCH
|
||||
elif [[ "$RECLONE" == "yes" ]]; then
|
||||
# if it does exist then simulate what clone does if asked to RECLONE
|
||||
cd $GIT_DEST
|
||||
# set the url to pull from and fetch
|
||||
git remote set-url origin $GIT_REMOTE
|
||||
git fetch origin
|
||||
# remove the existing ignored files (like pyc) as they cause breakage
|
||||
# (due to the py files having older timestamps than our pyc, so python
|
||||
# thinks the pyc files are correct using them)
|
||||
sudo git clean -f -d
|
||||
git checkout -f origin/$GIT_BRANCH
|
||||
# a local branch might not exist
|
||||
git branch -D $GIT_BRANCH || true
|
||||
git checkout -b $GIT_BRANCH
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue