git: match native agent workflows

This commit is contained in:
2026-11-06 19:07:28 +00:00
parent b5462cc366
commit 6daa53cca4
11 changed files with 1641 additions and 75 deletions
+7 -5
View File
@@ -116,7 +116,7 @@ pub fn set(repo: &gix::Repository, name: &str, url: &str, add: bool) -> Result<R
},
));
}
// Replace all URL occurrences (including duplicate sections), preserving other keys/comments.
// Change URL values in place, preserving config order and other keys/comments.
if !add {
let ids: Vec<_> = config
.sections_and_ids_by_name("remote")
@@ -131,17 +131,19 @@ pub fn set(repo: &gix::Repository, name: &str, url: &str, add: bool) -> Result<R
.collect();
for id in ids {
if let Some(mut section) = config.section_mut_by_id(id) {
while section.remove("url").is_some() {}
section
.set("url", url.as_str())
.map_err(|e| error("remote config", e))?;
}
}
}
let mut section = config
.section_mut_or_create_new("remote", name)
.map_err(|e| error("remote config", e))?;
section
.push("url", Some(url.as_str().into()))
.map_err(|e| error("remote config", e))?;
if add {
section
.push("url", Some(url.as_str().into()))
.map_err(|e| error("remote config", e))?;
section
.push(
"fetch",