Skip to content

Commit

Permalink
add ability to perform a sparse checkout
Browse files Browse the repository at this point in the history
Signed-off-by: Casey Braithwaite <[email protected]>
  • Loading branch information
caseybraithwaite committed Apr 12, 2024
1 parent 702bf5a commit 05da202
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion assets/in
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ configure_credentials "$payload"

uri=$(jq -r '.source.uri // ""' <<< "$payload")
branch=$(jq -r '.source.branch // ""' <<< "$payload")
sparse_paths="$(jq -r '(.source.sparse_paths // ["."])[]' <<< "$payload")" # those "'s are important
git_config_payload=$(jq -r '.source.git_config // []' <<< "$payload")
ref=$(jq -r '.version.ref // "HEAD"' <<< "$payload")
override_branch=$(jq -r '.version.branch // ""' <<< "$payload")
Expand Down Expand Up @@ -89,15 +90,25 @@ elif [ -n "$tag_filter" ] || [ -n "$tag_regex" ] || [ "$fetch_tags" == "true" ]
tagflag="--tags"
fi

nocheckoutflag=""
if [ "$sparse_paths" != "." ] && [ "$sparse_paths" != "" ]; then
nocheckoutflag=" --no-checkout"
fi

if [ "$disable_git_lfs" == "true" ]; then
# skip the fetching of LFS objects for all following git commands
export GIT_LFS_SKIP_SMUDGE=1
fi

git clone --single-branch $depthflag $uri $branchflag $destination $tagflag
git clone --single-branch $depthflag $uri $branchflag $destination $tagflag $nocheckoutflag

cd $destination

if [ "$sparse_paths" != "." ] && [ "$sparse_paths" != "" ]; then
git config core.sparseCheckout true
echo "$sparse_paths" >> ./.git/info/sparse-checkout
fi

git fetch origin refs/notes/*:refs/notes/* $tagflag

if [ "$depth" -gt 0 ]; then
Expand Down

0 comments on commit 05da202

Please sign in to comment.