mirror of
https://github.com/Dasemu/Grove.git
synced 2026-11-26 23:36:11 +00:00
feat: manage namespaces/providers and open worktrees in editors
- grove group add|remove|list and grove provider add|remove|list edit config.toml (validated first, previous file kept as config.toml.bak) - grove open [group/]repo[@branch] launches Zed, VS Code, Claude Code (in a terminal) or Claude Desktop; [open] config for defaults, terminal and own launchers; grove new --open - GUI: provider/namespace forms and removal in Settings, Open buttons on repos and worktrees, open-after-create on New repository - docs/phase8.md, DECISIONS 10-11 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011GZUAGhGYoiLvmfXweQnDY
This commit is contained in:
13 files changed
+2075
-25
No files matched your search
@@ -336,6 +336,53 @@ pub fn group_name(entry: &str) -> &str {
|
||||
entry.split(" → ").next().unwrap_or(entry)
|
||||
}
|
||||
|
||||
/// What the "Add or change a namespace" form holds.
|
||||
pub struct GroupForm {
|
||||
pub name: String,
|
||||
pub primary: String,
|
||||
/// Empty: no mirror.
|
||||
pub mirror: String,
|
||||
pub owner: String,
|
||||
pub mirror_owner: String,
|
||||
/// "default" leaves the global policy in force.
|
||||
pub snapshots: String,
|
||||
pub replace: bool,
|
||||
}
|
||||
|
||||
/// `grove group add ...` for the namespace form.
|
||||
pub fn group_add_args(f: &GroupForm) -> Vec<String> {
|
||||
let mut a: Vec<String> = vec![
|
||||
"group".into(),
|
||||
"add".into(),
|
||||
f.name.trim().to_string(),
|
||||
"--primary".into(),
|
||||
f.primary.clone(),
|
||||
];
|
||||
let mirror = f.mirror.trim();
|
||||
if !mirror.is_empty() {
|
||||
a.extend(["--mirror-to".into(), mirror.to_string()]);
|
||||
}
|
||||
if !f.owner.trim().is_empty() {
|
||||
a.extend([
|
||||
"--owner".into(),
|
||||
format!("{}={}", f.primary, f.owner.trim()),
|
||||
]);
|
||||
}
|
||||
if !mirror.is_empty() && !f.mirror_owner.trim().is_empty() {
|
||||
a.extend([
|
||||
"--owner".into(),
|
||||
format!("{mirror}={}", f.mirror_owner.trim()),
|
||||
]);
|
||||
}
|
||||
if !f.snapshots.is_empty() && f.snapshots != "default" {
|
||||
a.extend(["--snapshots".into(), f.snapshots.clone()]);
|
||||
}
|
||||
if f.replace {
|
||||
a.push("--replace".into());
|
||||
}
|
||||
a
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -501,4 +548,46 @@ mod tests {
|
||||
assert_eq!(s[3].1[0].1, "grove-config on gitea");
|
||||
assert_eq!(group_name("work → gitea"), "work");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn group_form_becomes_group_add_args() {
|
||||
let mut f = GroupForm {
|
||||
name: " oss ".into(),
|
||||
primary: "gh".into(),
|
||||
mirror: String::new(),
|
||||
owner: String::new(),
|
||||
mirror_owner: "ignored without a mirror".into(),
|
||||
snapshots: "default".into(),
|
||||
replace: false,
|
||||
};
|
||||
assert_eq!(
|
||||
group_add_args(&f),
|
||||
["group", "add", "oss", "--primary", "gh"]
|
||||
);
|
||||
f.mirror = "gitea".into();
|
||||
f.owner = "Zenvairo".into();
|
||||
f.mirror_owner = "Org".into();
|
||||
f.snapshots = "none".into();
|
||||
f.replace = true;
|
||||
assert_eq!(
|
||||
group_add_args(&f),
|
||||
[
|
||||
"group",
|
||||
"add",
|
||||
"oss",
|
||||
"--primary",
|
||||
"gh",
|
||||
"--mirror-to",
|
||||
"gitea",
|
||||
"--owner",
|
||||
"gh=Zenvairo",
|
||||
"--owner",
|
||||
"gitea=Org",
|
||||
"--snapshots",
|
||||
"none",
|
||||
"--replace"
|
||||
]
|
||||
);
|
||||
assert!(crate::bridge::validate(&group_add_args(&f)).is_ok());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user