Skip to content

Commit 7cc0f57

Browse files
wellnanagrandizzy
andauthored
fix: normalize path separators in git submodule URL lookup (#11826)
* fix: normalize path separators in git submodule URL lookup * make ci happy * fix fmt * use dunce::canonicalize * removed the path separator replacement and now rely only on `dunce::canonicalize` * Update proper test * Fix --------- Co-authored-by: grandizzy <[email protected]>
1 parent 754717c commit 7cc0f57

File tree

5 files changed

+6
-9
lines changed

5 files changed

+6
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ futures.workspace = true
4242
indicatif.workspace = true
4343
itertools.workspace = true
4444
mimalloc = { workspace = true, optional = true }
45+
path-slash.workspace = true
4546
rayon.workspace = true
4647
regex = { workspace = true, default-features = false }
4748
serde_json.workspace = true

crates/cli/src/utils/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use foundry_common::{
88
};
99
use foundry_config::{Chain, Config};
1010
use itertools::Itertools;
11+
use path_slash::PathExt;
1112
use regex::Regex;
1213
use serde::de::DeserializeOwned;
1314
use std::{
@@ -718,13 +719,9 @@ ignore them in the `.gitignore` file."
718719
}
719720

720721
/// Get the URL of a submodule from git config
721-
pub fn submodule_url(self, path: impl AsRef<OsStr>) -> Result<Option<String>> {
722+
pub fn submodule_url(self, path: &Path) -> Result<Option<String>> {
722723
self.cmd()
723-
.args([
724-
"config",
725-
"--get",
726-
&format!("submodule.{}.url", path.as_ref().to_string_lossy()),
727-
])
724+
.args(["config", "--get", &format!("submodule.{}.url", path.to_slash_lossy())])
728725
.get_stdout_lossy()
729726
.map(|url| Some(url.trim().to_string()))
730727
}

crates/forge/src/cmd/remove.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ impl RemoveArgs {
3333
let config = self.load_config()?;
3434
let (root, paths, _) = super::update::dependencies_paths(&self.dependencies, &config)?;
3535
let git_modules = root.join(".git/modules");
36-
3736
let git = Git::new(&root);
3837
let mut lockfile = Lockfile::new(&config.root).with_git(&git);
3938
let _synced = lockfile.sync(config.install_lib_dir())?;

crates/forge/tests/cli/install.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ Installing forge-std in [..] (url: Some("https://github.com/foundry-rs/forge-std
108108
};
109109

110110
let remove = |cmd: &mut TestCommand, target: &str| {
111-
// TODO: flaky behavior with URL, sometimes it is None, sometimes it is Some("https://github.com/lib/forge-std")
112111
cmd.forge_fuse().args(["remove", "--force", target]).assert_success().stdout_eq(str![[
113112
r#"
114-
Removing 'forge-std' in [..], (url: [..], tag: None)
113+
Removing 'forge-std' in [..], (url: Some("https://github.com/foundry-rs/forge-std"), tag: None)
115114
116115
"#
117116
]]);

0 commit comments

Comments
 (0)