From 1a71141d85d221653c40b80efffef3e652ed3b07 Mon Sep 17 00:00:00 2001 From: Ryann Graham Date: Fri, 3 Nov 2023 09:47:21 -0700 Subject: [PATCH] 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 --- assets/check | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/check b/assets/check index 4a81bb1..b59e0ac 100755 --- a/assets/check +++ b/assets/check @@ -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