git: match native agent workflows
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user