-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 sparse checkout to git #3646
Conversation
Hi @a-rothwell. Thanks for your PR. I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
/test pull-tekton-pipeline-integration-tests |
/cc @sbwsg |
pkg/git/git.go
Outdated
} | ||
file, err := os.OpenFile(filepath.Join(cwd, ".git/info/sparse-checkout"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) | ||
if err != nil { | ||
logger.Errorf("failed to open sparse-checkout file; err: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: no need for err
in the logged message here. Suggest "failed to open sparse-checkout file: %v"
. Similar comment for the other messages passed to logger.Errorf
in this func.
cmd/git-init/main.go
Outdated
@@ -39,6 +39,8 @@ func init() { | |||
flag.BoolVar(&fetchSpec.Submodules, "submodules", true, "Initialize and fetch Git submodules") | |||
flag.UintVar(&fetchSpec.Depth, "depth", 1, "Perform a shallow clone to this depth") | |||
flag.StringVar(&terminationMessagePath, "terminationMessagePath", "/tekton/termination", "Location of file containing termination message") | |||
flag.StringVar(&fetchSpec.SparseCheckoutDirectories, "sparseCheckoutDirectories", "", "String of directory patterns separated by a delimiter") | |||
flag.StringVar(&fetchSpec.SparseCheckoutDelimiter, "sparseCheckoutDelimiter", ";", "Delimiter used to separate sparse checkout directories") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need that level of granularity as a flag
Moreover the delimiter would cause some issues if the user doesn't quote the ";", it will be interepreted as another command.
What about removing the flag and setting the delimiter as a standard comma "," ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is true, I understand how semicolons could cause issues for users.
Removing the delimiter flag and using a comma will make it simpler.
pkg/git/git_test.go
Outdated
sparsePatterns = append(sparsePatterns, scanner.Text()) | ||
} | ||
|
||
if !reflect.DeepEqual(dirPatterns, sparsePatterns) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about using cmp.Diff, which is a library used thought-out all the tests in pipeline ? correct me if I am wrong but it does the same thing ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmp.Diff will work here. I will make that change!
The following is the coverage report on the affected files.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sbwsg The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@a-rothwell thanks for making those changes. You'll need to squash your commits into 1 prior to merge. |
aa42142
to
82e6a68
Compare
The following is the coverage report on the affected files.
|
/lgtm Thanks 🙇🏽 |
it woudl be great if we can have the git-clone task updated to support this feature too 🙏🏽 @a-rothwell |
Thank you both for helping me with this! |
Changes
Hi,
I have added functionality to support sparse-checkout for git
This works by enabling the feature in the git config and then updating the sparse-checkout file before fetch.
The feature request is here
I have also added a test to check that .git/info/sparse-checkout is updated as expected
Thanks!
/kind feature
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Double check this list of stuff that's easy to miss:
cmd
dir, please updatethe release Task to build and release this image.
Reviewer Notes
If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.
Release Notes