Skip to content

Commit f3625e0

Browse files
authored
fix(forge): populate the git submodule url from git config (#11437)
* update mod.rs * populate the git submodule url * revert cmd.rs
1 parent ecb5b5f commit f3625e0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

crates/cli/src/utils/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,18 @@ ignore them in the `.gitignore` file."
717717
self.cmd().stderr(self.stderr()).args(["submodule", "sync"]).exec().map(drop)
718718
}
719719

720+
/// Get the URL of a submodule from git config
721+
pub fn submodule_url(self, path: impl AsRef<OsStr>) -> Result<Option<String>> {
722+
self.cmd()
723+
.args([
724+
"config",
725+
"--get",
726+
&format!("submodule.{}.url", path.as_ref().to_string_lossy()),
727+
])
728+
.get_stdout_lossy()
729+
.map(|url| Some(url.trim().to_string()))
730+
}
731+
720732
pub fn cmd(self) -> Command {
721733
let mut cmd = Self::cmd_no_root();
722734
cmd.current_dir(self.root);

crates/forge/src/cmd/remove.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ impl RemoveArgs {
4242
git.rm(self.force, &paths)?;
4343

4444
// remove all the dependencies from .git/modules
45-
for (Dependency { name, url, tag, .. }, path) in self.dependencies.iter().zip(&paths) {
45+
for (Dependency { name, tag, .. }, path) in self.dependencies.iter().zip(&paths) {
46+
// Get the URL from git submodule config instead of using the parsed dependency URL
47+
let url = git.submodule_url(path).unwrap_or(None);
4648
sh_println!("Removing '{name}' in {}, (url: {url:?}, tag: {tag:?})", path.display())?;
4749
let _ = lockfile.remove(path);
4850
std::fs::remove_dir_all(git_modules.join(path))?;

0 commit comments

Comments
 (0)