Skip to content

Commit 1a71141

Browse files
committed
check: use bare clone
The check container doesn't make any use of an actual checkout, but on large repositories the time to checkout after fetching can be 90% or more of the overall time to clone. Because the --bare option prevents the --branch option from being setting the refspec in the config we have to do it as a follow-up step. Instead of relying solely on the config having the refspec set correctly, we can also explicitly specify the branch when fetching if one is set. Signed-off-by: Ryann Graham <[email protected]>
1 parent 0a2b7d7 commit 1a71141

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

assets/check

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,20 @@ export GIT_LFS_SKIP_SMUDGE=1
4848

4949
if [ -d $destination ]; then
5050
cd $destination
51-
git fetch $tagflag -f
52-
git reset --hard FETCH_HEAD
51+
git fetch origin $tagflag $branch -f
52+
git reset --soft FETCH_HEAD
5353
else
5454
branchflag=""
5555
if [ -n "$branch" ]; then
5656
branchflag="--branch $branch"
5757
fi
5858

59-
git clone --single-branch $uri $branchflag $destination $tagflag
59+
git clone --bare --single-branch $uri $branchflag $destination $tagflag
6060
cd $destination
61+
# bare clones don't configure the refspec
62+
if [ -n "$branch" ]; then
63+
git remote set-branches --add origin $branch
64+
fi
6165
fi
6266

6367
if [ -n "$ref" ] && git cat-file -e "$ref"; then

0 commit comments

Comments
 (0)