-
Notifications
You must be signed in to change notification settings - Fork 54
74 git submodule support #485
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
base: main
Are you sure you want to change the base?
Conversation
Add support for initializing and updating git submodules during repository cloning.
Added GitCloneSubmodules option to support recursive submodule initialization.
Resolved issues with git submodule handling for better cloning and URL resolution.
Resolved issues with git submodule handling to ensure robust cloning and URL resolution without relying on git binary calls.
*test.go file addendum
Adding tests for Submodules and two missing
|
I have read the CLA Document and I hereby sign the CLA |
johnstcn
left a comment
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.
Thanks for working on this @bjornrobertsson !
I have some comments below, and I think it would also be worthwhile adding an integration test (see: integration/integration_test.go and testutil/gittest/gittest.go).
| // resolveSubmoduleURL resolves a potentially relative submodule URL against the parent repository URL | ||
| // ResolveSubmoduleURLForTest is exported for testing resolveSubmoduleURL logic | ||
| func ResolveSubmoduleURLForTest(parentURL, submoduleURL string) (string, error) { |
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: the naming of this function implies that it is only used in tests, which is false. suggestion: ResolveSubmoduleURL.
| { | ||
| name: "absolute", | ||
| parentURL: "https://example.com/org/main.git", | ||
| subURL: "https://github.com/other/repo.git", | ||
| expect: "https://github.com/other/repo.git", | ||
| }, | ||
| { | ||
| name: "relativeSibling", | ||
| parentURL: "https://example.com/org/main.git", | ||
| subURL: "../deps/lib.git", | ||
| expect: "https://example.com/org/deps/lib.git", | ||
| }, | ||
| { | ||
| name: "relativeChild", | ||
| parentURL: "https://example.com/org/main.git", | ||
| subURL: "./extras/tool.git", | ||
| expect: "https://example.com/org/main.git/extras/tool.git", | ||
| }, | ||
| { | ||
| name: "badParent", | ||
| parentURL: "://bad", | ||
| subURL: "./child", | ||
| expectErr: "parse parent URL", | ||
| }, |
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.
Please also test with the URL schemes from TestSetupRepoAuth:
- SSH with scheme (
ssh://host.tld/repo) - SSH without scheme (
[email protected]:repo/path) - Git scheme (
git://[email protected]:repo/path) - Absolute local path (
/path/to/repo) - Relative paths without
./..(path/to/repo)
| if opts.Submodules { | ||
| err = initSubmodules(ctx, logf, repo, opts) | ||
| if err != nil { | ||
| return true, fmt.Errorf("init submodules: %w", 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.
We can detect the presence/absence of submodules via .gitmodules after cloning the remote. This would remove the need to have a separate config option.
Add submodule cloning support via native Go implementation
Summary
This PR resolves/mitigates #74
Changes
Since the existing submodule support in
git.godepends on execution of the git binary, this implementation circumvents that limitation by traversing the tree to clone submodules natively in Go.Behavior