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

fix(forge): update submodules after dependency checkout #7142

Merged
merged 3 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/forge/bin/cmd/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl InitArgs {
git.submodule_init()?;
} else {
// if not shallow, initialize and clone submodules (without fetching latest)
git.submodule_update(false, false, true, true, None::<PathBuf>)?;
git.submodule_update(false, false, true, true, std::iter::empty::<PathBuf>())?;
}
} else {
// if target is not empty
Expand Down
23 changes: 19 additions & 4 deletions crates/forge/bin/cmd/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@ impl Installer<'_> {
// checkout the tag if necessary
self.git_checkout(&dep, path, false)?;

trace!("updating dependency submodules recursively");
self.git.root(path).submodule_update(
false,
false,
false,
true,
std::iter::empty::<PathBuf>(),
)?;

// remove git artifacts
fs::remove_dir_all(path.join(".git"))?;

Expand All @@ -259,6 +268,15 @@ impl Installer<'_> {
// checkout the tag if necessary
self.git_checkout(&dep, path, true)?;

trace!("updating dependency submodules recursively");
self.git.root(path).submodule_update(
false,
false,
false,
true,
std::iter::empty::<PathBuf>(),
)?;

if !self.no_commit {
self.git.add(Some(path))?;
}
Expand Down Expand Up @@ -315,10 +333,7 @@ impl Installer<'_> {
let path = path.strip_prefix(self.git.root).unwrap();

trace!(?dep, url, ?path, "installing git submodule");
self.git.submodule_add(true, url, path)?;

trace!("initializing submodule recursively");
self.git.submodule_update(false, false, false, true, Some(path))
self.git.submodule_add(true, url, path)
}

fn git_checkout(self, dep: &Dependency, path: &Path, recurse: bool) -> Result<String> {
Expand Down
Loading