fix: make bundle provenance portable to Windows

Provenance records stored OS-native path separators, making
installed-bundles.yaml non-portable; slug derivation treated a Windows
drive letter as an scp host and swallowed the whole path into one
sanitized segment. Store paths are now always forward-slashed and
backslashes normalize before URL parsing. Test fixture repos commit a
'* -text' .gitattributes so clone-side autocrlf cannot rewrite content
assertions.
This commit is contained in:
2026-08-24 11:15:13 -06:00
parent 89df8ec1ca
commit 9541a094d8
+5 -4
View File
@@ -1076,6 +1076,7 @@ fn strip_ref_suffix(url: &str) -> &str {
fn split_host_and_path(url: &str) -> (String, String) { fn split_host_and_path(url: &str) -> (String, String) {
let url = strip_ref_suffix(url); let url = strip_ref_suffix(url);
let url = &url.replace('\\', "/");
if let Some((_, rest)) = url.split_once("://") { if let Some((_, rest)) = url.split_once("://") {
let (authority, path) = rest.split_once('/').unwrap_or((rest, "")); let (authority, path) = rest.split_once('/').unwrap_or((rest, ""));
let host = authority.rsplit_once('@').map_or(authority, |(_, h)| h); let host = authority.rsplit_once('@').map_or(authority, |(_, h)| h);
@@ -1544,10 +1545,8 @@ fn record_written_file(
} }
fn provenance_path(dst: &Path) -> String { fn provenance_path(dst: &Path) -> String {
dst.strip_prefix(paths::config_dir()) let rel = dst.strip_prefix(paths::config_dir()).unwrap_or(dst);
.unwrap_or(dst) rel.to_string_lossy().replace('\\', "/")
.to_string_lossy()
.into_owned()
} }
/// Record the mcp.json entries the merge actually wrote, in one flush right /// Record the mcp.json entries the merge actually wrote, in one flush right
@@ -2807,6 +2806,7 @@ mod tests {
fn init_git_repo(dir: &Path) -> String { fn init_git_repo(dir: &Path) -> String {
run_git(vec!["init".into(), "-q".into(), dir.as_os_str().into()]).unwrap(); run_git(vec!["init".into(), "-q".into(), dir.as_os_str().into()]).unwrap();
fs::write(dir.join(".gitattributes"), "* -text\n").unwrap();
commit_file(dir, "seed.txt", "one") commit_file(dir, "seed.txt", "one")
} }
@@ -2860,6 +2860,7 @@ mod tests {
fn init_bundle_repo(dir: &Path) -> String { fn init_bundle_repo(dir: &Path) -> String {
run_git(vec!["init".into(), "-q".into(), dir.as_os_str().into()]).unwrap(); run_git(vec!["init".into(), "-q".into(), dir.as_os_str().into()]).unwrap();
fs::write(dir.join(".gitattributes"), "* -text\n").unwrap();
commit_file(dir, ".seed", "seed") commit_file(dir, ".seed", "seed")
} }