-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(spm): recursively update submodules after checkout #7292
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -171,6 +171,32 @@ impl Git { | |||||
| Ok(()) | ||||||
| } | ||||||
|
|
||||||
| pub fn update_submodules(&self) -> Result<()> { | ||||||
| debug!("updating submodules in {}", self.dir.display()); | ||||||
|
|
||||||
| let exec = |cmd: Expression| match cmd.stderr_to_stdout().stdout_capture().unchecked().run() | ||||||
| { | ||||||
| Ok(res) => { | ||||||
| if res.status.success() { | ||||||
| Ok(()) | ||||||
| } else { | ||||||
| Err(eyre!( | ||||||
| "git failed: {cmd:?} {}", | ||||||
| String::from_utf8(res.stdout).unwrap() | ||||||
|
||||||
| String::from_utf8(res.stdout).unwrap() | |
| String::from_utf8_lossy(&res.stdout) |
Copilot
AI
Dec 14, 2025
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.
The exec closure is duplicated from the update_ref method above (lines 73-86). Consider extracting this into a private helper method to eliminate code duplication and improve maintainability. This pattern appears to be used for executing git commands with consistent error handling.
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.
The new submodule update functionality lacks test coverage. Consider adding a unit test for the
update_submodulesmethod or an integration test that verifies submodules are properly initialized for SPM packages that depend on them (e.g., testing with a package likeapple/swift-protobuf>= 1.31.0 which uses submodules).