Skip to content

Commit 13f45e0

Browse files
Merge pull request #7 from codefresh-io/fix_spare_clone
Fix spare clone
2 parents ba8e7ab + 45a8806 commit 13f45e0

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

start.sh

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,24 @@ cd $WORKING_DIRECTORY
4646
git config --global advice.detachedhead false
4747
git config --global credential.helper "/bin/sh -c 'echo username=$USERNAME; echo password=$PASSWORD'"
4848

49+
if [ -n "$SPARE_CHECKOUT" ]; then
50+
echo "spare checkout"
51+
if [ -d "$CLONE_DIR" ]; then
52+
echo "folder exists - no need to init"
53+
cd $CLONE_DIR
54+
else
55+
git init $CLONE_DIR
56+
chmod -R 774 $CLONE_DIR
57+
cd $CLONE_DIR
58+
git remote add origin $REPO
59+
git config core.sparsecheckout true
60+
echo "$SOURCE/*" >> .git/info/sparse-checkout
61+
fi
62+
63+
git pull --depth=1 origin $REVISION
64+
exit 0
65+
fi
66+
4967
# Check if the cloned dir already exists from previous builds
5068
if [ -d "$CLONE_DIR" ]; then
5169

@@ -96,16 +114,6 @@ if [ -d "$CLONE_DIR" ]; then
96114
fi
97115
else
98116

99-
if [ -n "$SPARE_CHECKOUT" ]; then
100-
echo "spare checkout"
101-
git init $CLONE_DIR
102-
chmod -R 774 $CLONE_DIR
103-
cd $CLONE_DIR
104-
git remote add origin $REPO
105-
git config core.sparsecheckout true
106-
echo "$SOURCE/*" >> .git/info/sparse-checkout
107-
git pull --depth=1 origin $REVISION
108-
else
109117
# Clone a fresh copy
110118
echo "cloning $REPO"
111119
git_retry git clone $REPO $CLONE_DIR
@@ -115,6 +123,4 @@ else
115123
git checkout $REVISION
116124
fi
117125

118-
fi
119-
120126
fi

0 commit comments

Comments
 (0)