Skip to content

Commit

Permalink
fix(forge): update submodules after dependency checkout (#7142)
Browse files Browse the repository at this point in the history
* fix(forge): update submodules after dependency checkout

* update submodules after checkout

* std::iter::empty
  • Loading branch information
klkvr committed Feb 15, 2024
1 parent 8cebc1f commit a170021
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
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

0 comments on commit a170021

Please sign in to comment.