Skip to content

Commit

Permalink
check: use bare clone
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rmg committed Nov 20, 2023
1 parent 0a2b7d7 commit 1a71141
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions assets/check
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,20 @@ export GIT_LFS_SKIP_SMUDGE=1

if [ -d $destination ]; then
cd $destination
git fetch $tagflag -f
git reset --hard FETCH_HEAD
git fetch origin $tagflag $branch -f
git reset --soft FETCH_HEAD
else
branchflag=""
if [ -n "$branch" ]; then
branchflag="--branch $branch"
fi

git clone --single-branch $uri $branchflag $destination $tagflag
git clone --bare --single-branch $uri $branchflag $destination $tagflag
cd $destination
# bare clones don't configure the refspec
if [ -n "$branch" ]; then
git remote set-branches --add origin $branch
fi
fi

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

0 comments on commit 1a71141

Please sign in to comment.