Skip to content
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
12 changes: 12 additions & 0 deletions crates/cli/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<OsStr>) -> Result<Option<String>> {
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);
Expand Down
4 changes: 3 additions & 1 deletion crates/forge/src/cmd/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))?;
Expand Down
Loading