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 sparse checkout to git #3646

Merged
merged 1 commit into from
Jan 26, 2021

Conversation

a-rothwell
Copy link
Contributor

@a-rothwell a-rothwell commented Dec 23, 2020

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:

  • Includes tests (if functionality changed/added)
  • Includes docs (if user facing)
  • Commit messages follow commit message best practices
  • Release notes block has been filled in or deleted (only if no user facing changes)

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

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

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. labels Dec 23, 2020
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 23, 2020
@tekton-robot
Copy link
Collaborator

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@tekton-robot tekton-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Dec 23, 2020
@dlorenc
Copy link
Contributor

dlorenc commented Dec 24, 2020

/ok-to-test

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 24, 2020
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/git/git.go 55.6% 55.4% -0.2

@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 24, 2020
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/git/git.go 55.6% 55.4% -0.2

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/git/git.go 55.6% 55.4% -0.2

@a-rothwell
Copy link
Contributor Author

/test pull-tekton-pipeline-integration-tests

@chmouel
Copy link
Member

chmouel commented Jan 21, 2021

/cc @sbwsg

@tekton-robot tekton-robot requested a review from a user January 21, 2021 20:56
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)
Copy link

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.

pkg/git/git.go Show resolved Hide resolved
@@ -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")
Copy link
Member

@chmouel chmouel Jan 22, 2021

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 "," ?

Copy link
Contributor Author

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.

sparsePatterns = append(sparsePatterns, scanner.Text())
}

if !reflect.DeepEqual(dirPatterns, sparsePatterns) {
Copy link
Member

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 ?

Copy link
Contributor Author

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!

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/git/git.go 55.6% 55.0% -0.5

@tekton-robot
Copy link
Collaborator

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 25, 2021
@ghost
Copy link

ghost commented Jan 25, 2021

@a-rothwell thanks for making those changes. You'll need to squash your commits into 1 prior to merge.

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/git/git.go 55.6% 55.0% -0.5

@chmouel
Copy link
Member

chmouel commented Jan 26, 2021

/lgtm

Thanks 🙇🏽

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 26, 2021
@chmouel
Copy link
Member

chmouel commented Jan 26, 2021

it woudl be great if we can have the git-clone task updated to support this feature too 🙏🏽 @a-rothwell

@tekton-robot tekton-robot merged commit 26d303d into tektoncd:master Jan 26, 2021
@a-rothwell
Copy link
Contributor Author

Thank you both for helping me with this!
I will update the task in the catalog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants