diff --git a/crates/cli/src/utils/mod.rs b/crates/cli/src/utils/mod.rs index e5ccb4612211b..f632e0839f753 100644 --- a/crates/cli/src/utils/mod.rs +++ b/crates/cli/src/utils/mod.rs @@ -711,6 +711,18 @@ ignore them in the `.gitignore` file." self.cmd().stderr(self.stderr()).args(["submodule", "sync"]).exec().map(drop) } + /// Get the URL of a submodule from git config + pub fn submodule_url(self, path: impl AsRef) -> Result> { + self.cmd() + .args([ + "config", + "--get", + &format!("submodule.{}.url", path.as_ref().to_string_lossy()), + ]) + .get_stdout_lossy() + .map(|url| Some(url.trim().to_string())) + } + pub fn cmd(self) -> Command { let mut cmd = Self::cmd_no_root(); cmd.current_dir(self.root); diff --git a/crates/forge/src/cmd/remove.rs b/crates/forge/src/cmd/remove.rs index 9e4629a5b726b..f4cb60de039bd 100644 --- a/crates/forge/src/cmd/remove.rs +++ b/crates/forge/src/cmd/remove.rs @@ -42,7 +42,9 @@ impl RemoveArgs { git.rm(self.force, &paths)?; // remove all the dependencies from .git/modules - for (Dependency { name, url, tag, .. }, path) in self.dependencies.iter().zip(&paths) { + for (Dependency { name, tag, .. }, path) in self.dependencies.iter().zip(&paths) { + // Get the URL from git submodule config instead of using the parsed dependency URL + let url = git.submodule_url(path).unwrap_or(None); sh_println!("Removing '{name}' in {}, (url: {url:?}, tag: {tag:?})", path.display())?; let _ = lockfile.remove(path); std::fs::remove_dir_all(git_modules.join(path))?;