mirror of
https://github.com/openai/codex.git
synced 2026-05-06 06:12:59 +03:00
fix: recognize windows local marketplace sources
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user