-
Notifications
You must be signed in to change notification settings - Fork 187
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 support for Git submodules with go-git #327
Conversation
7386b7d
to
19cf29e
Compare
d3a9679
to
46343a8
Compare
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.
API and implementation look 👍 I think some tests are warranted here though.
Wouldn't that be testing go-git cloning that's covered in go-git? Any hits how to write this test or how to make our Git server serve submodules? For referece, I do test my PRs on real clusters: Without submodules:
With submodules:
|
[and]
I believe you. But did you test in advance all future changes to the code to make sure they didn't e.g., accidentally invert, or omit, the argument that is given to go-git? ;-)
I don't think you need to do anything special to the git server for submodules to work, other than serve more than one repo -- they are a client-side feature. There's already a bunch of scaffolding for creating a git server and getting stuff from it in gitrepository_controller_test.go, this won't be much of a stretch beyond that will it? |
I see no files being pushed to Git, can you give some hints how to setup submodules, I'm lost. |
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
46343a8
to
664a568
Compare
These lines init a git repo, create a file, commit it, and push to the test server: https://github.com/fluxcd/source-controller/blob/main/controllers/gitrepository_controller_test.go#L120-L156 If you prefer getting the files from testdata/, here's the equivalent from image-automation, that walks the filesystem and adds files from there: https://github.com/fluxcd/image-automation-controller/blob/main/controllers/update_test.go#L860 As for submodules: I haven't created submodules using go-git. It looks like go-git understands submodules (https://github.com/go-git/go-git/blob/master/_examples/submodule/main.go), but I'm not sure if it will create them. Might take a bit of fishing around in the go-git docs. |
225ecf5
to
2ef4c22
Compare
This commit adds a test specifically for RecurseSubmodules. It takes a bit more preparation, since it needs a repo using submodules to start with. go-git doesn't appear to support adding submodules programmatically, so the preparation is done in part by execing `git`. Signed-off-by: Michael Bridgen <michael@weave.works>
2ef4c22
to
681ddd5
Compare
This PR adds an optional field
.spec.recurseSubmodules
to the GitRepository API. When enabled, after the clone is created, initializes all submodules within, using their default settings. This option is available only when using thego-git
GitImplementation.Fix: #169
Addresses: fluxcd/flux2#326