Skip to content

Commit

Permalink
* avoid unecessary clone
Browse files Browse the repository at this point in the history
* workaround travis-ci broken build test
  • Loading branch information
Ali Abbas committed Apr 5, 2014
1 parent 7d722ae commit ff6c3be
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions binscripts/gvm-installer
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,34 @@ SRC_REPO=${SRC_REPO:-https://github.com/moovweb/gvm.git}
mac: brew install git
"

git clone --quiet "$SRC_REPO" "$GVM_DEST/$GVM_NAME" 2> /dev/null ||
display_error "Failed to clone from $SRC_REPO into $GVM_DEST/$GVM_NAME"
# Is gvm-installer being called from the origin repo?
# If so, skip the clone and source locally!
# This prevents, the CI to break on non-merge commits

GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)

if [[ -z "$GIT_ROOT" ]]
then
echo "Cloning from $SRC_REPO to $GVM_DEST/$GVM_NAME"

git clone --quiet "$SRC_REPO" "$GVM_DEST/$GVM_NAME" 2> /dev/null ||
display_error "Failed to clone from $SRC_REPO into $GVM_DEST/$GVM_NAME"
else
if [[ $GVM_DEST == *"$GIT_ROOT"* ]]
then
ln -s $GIT_ROOT $GVM_DEST
else
cp -r $GIT_ROOT $GVM_DEST/$GVM_NAME
fi
fi

# GVM_DEST may be a non-relative path
# i.e: gvm-installer master foo
pushd . > /dev/null

cd "$GVM_DEST/$GVM_NAME" && git checkout --quiet "$BRANCH" 2> /dev/null || display_error "Failed to checkout $BRANCH branch"

popd
popd > /dev/null

mv "$GVM_DEST/$GVM_NAME/.git" "$GVM_DEST/$GVM_NAME/git.bak"

Expand Down

0 comments on commit ff6c3be

Please sign in to comment.