feat(daemon): prune branches merged without a PR, protect long-lived ones

- Prune a worktree whose pushed tip a merge commit brought into the default
  branch (not on its first-parent history), with no forge needed.
- Never prune or keep from materializing main/master/development/... plus
  sync.prune_protected; this also stops a development->main PR pruning
  development.
- Follow repos transferred or renamed on the forge when listing merged PRs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-11-17 15:29:26 +01:00
1 parent c7899bcdc0
commit a1646bccb7
12 files changed
+323 -49

No files matched your search

+23
View File
@@ -167,6 +167,19 @@ pub struct Sync {
/// regenerable build output and dependency caches. Any other ignored file keeps it.
#[serde(default = "default_disposable")]
pub prune_disposable: Vec<String>,
/// Extra branches never pruned, on top of the built-in long-lived ones
/// (`prune::default_protected`) and the default branch. See [`Sync::protected_branches`].
#[serde(default)]
pub prune_protected: Vec<String>,
}
impl Sync {
/// Branches never pruned: the built-in long-lived ones plus `prune_protected`.
pub fn protected_branches(&self) -> Vec<String> {
let mut all = crate::prune::default_protected();
all.extend(self.prune_protected.iter().cloned());
all
}
}
impl Default for Sync {
@@ -180,6 +193,7 @@ impl Default for Sync {
purged_dir: default_purged_dir(),
prune_merged: true,
prune_disposable: default_disposable(),
prune_protected: Vec::new(),
}
}
}
@@ -457,10 +471,19 @@ name = "grove-config"
let c = Config::parse(base).unwrap();
assert!(c.sync.prune_merged);
assert!(c.sync.prune_disposable.iter().any(|d| d == "target"));
assert!(
c.sync
.protected_branches()
.iter()
.any(|b| b == "development")
);
let own = format!("{base}[sync]\nprune_merged=false\nprune_disposable=[\"out\"]\n");
let c = Config::parse(&own).unwrap();
assert!(!c.sync.prune_merged);
assert_eq!(c.sync.prune_disposable, vec!["out".to_string()]);
let t = format!("{base}[sync]\nprune_protected=[\"release\"]\n");
let p = Config::parse(&t).unwrap().sync.protected_branches();
assert!(p.iter().any(|b| b == "release") && p.iter().any(|b| b == "main"));
for bad in ["\"\"", "\"a/b\"", "\"..\""] {
let t = format!("{base}[sync]\nprune_disposable=[{bad}]\n");
assert!(Config::parse(&t).is_err(), "{bad}");