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

git: Add support for sparse checkout #850

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kane8n
Copy link

@kane8n kane8n commented Jan 6, 2025

Add the sparse checkout option to the gogit package.
This change is in preparation for adding the sparse checkout option to ImageAutomationController.

Reference:
https://github.com/go-git/go-git/blob/master/_examples/sparse-checkout/main.go

@kane8n kane8n force-pushed the support-sparse-checkout branch from 732fc20 to 19f2318 Compare January 6, 2025 04:25
@stefanprodan stefanprodan changed the title support sparse checkout git: Add support for sparse checkout Jan 6, 2025
@stefanprodan stefanprodan added the area/git Git and SSH related issues and pull requests label Jan 6, 2025
@stefanprodan
Copy link
Member

This change is in preparation for adding the sparse checkout option to ImageAutomationController.

Hey @kane8n, sparse checkout could be very useful in source-controller as well.

PS. please run make tidy and force push so that CI can run.

@kane8n kane8n force-pushed the support-sparse-checkout branch from 19f2318 to ed54e74 Compare January 6, 2025 12:30
@kane8n kane8n requested a review from stefanprodan as a code owner January 6, 2025 12:30
@stefanprodan
Copy link
Member

stefanprodan commented Jan 9, 2025

Hey @pjbgf is sparse checkout stable in go-git, can it be used in IAC to commit changes back to the upstream branch? I'm reading the go-git code and I assume this can't work, especially when IAC needs to push a new branch.

Copy link
Member

@matheuscscp matheuscscp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution @kane8n!

Copy link
Member

@pjbgf pjbgf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @pjbgf is sparse checkout stable in go-git, can it be used in IAC to commit changes back to the upstream branch? I'm reading the go-git code and I assume this can't work, especially when IAC needs to push a new branch.

@stefanprodan this would certainly be useful for SC. For IAC, it should also work however I haven't tested pushing from a repository that was sparse checkout using go-git. If that ends up being a problem, we have two options: fix the issue in go-git which we should be able to do at pace these days, or b) just opt-out of sparse checkout in IAC.

name: "Default branch",
branch: "master",
filesCreated: map[string]string{"dir1/branch": "init1"},
sparseCheckoutDirectories: []string{"dir1"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the API enables multiple dirs to be set, we should add a test case that covers more than one dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/git Git and SSH related issues and pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants