Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to perform a sparse checkout #427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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