fix: recognize windows local marketplace sources

This commit is contained in:
xli-oai
2026-04-14 16:49:06 -07:00
parent 3cc689fb23
commit 05a9d7af99
2 changed files with 25 additions and 3 deletions

View File

@@ -275,9 +275,15 @@ mod tests {
);
let config = fs::read_to_string(codex_home.path().join(codex_config::CONFIG_TOML_FILE))?;
assert!(config.contains("[marketplaces.debug]"));
assert!(config.contains("source_type = \"local\""));
assert!(config.contains(&format!("source = \"{expected_source}\"")));
let config: toml::Value = toml::from_str(&config)?;
assert_eq!(
config["marketplaces"]["debug"]["source_type"].as_str(),
Some("local")
);
assert_eq!(
config["marketplaces"]["debug"]["source"].as_str(),
Some(expected_source.as_str())
);
Ok(())
}

View File

@@ -124,12 +124,14 @@ fn normalize_git_url(url: &str) -> String {
}
fn looks_like_local_path(source: &str) -> bool {
let path = Path::new(source);
source.starts_with("./")
|| source.starts_with("../")
|| source.starts_with('/')
|| source.starts_with("~/")
|| source == "."
|| source == ".."
|| path.is_absolute()
}
fn resolve_local_source_path(source: &str) -> Result<PathBuf, MarketplaceAddError> {
@@ -310,6 +312,20 @@ mod tests {
assert!(path.is_absolute());
}
#[cfg(windows)]
#[test]
fn windows_absolute_path_source_parses() {
let source =
parse_marketplace_source(r"C:\temp\marketplace", /*explicit_ref*/ None).unwrap();
assert_eq!(
source,
MarketplaceSource::Local {
path: PathBuf::from(r"C:\temp\marketplace"),
}
);
}
#[test]
fn local_file_source_is_rejected() {
let tempdir = TempDir::new().unwrap();