mirror of
https://github.com/Dasemu/Grove.git
synced 2026-11-26 23:36:11 +00:00
feat(daemon): prune worktrees merged through a pull request
The daemon asks the forge (GitHub, Gitea/Forgejo) which pull requests were merged and removes the local worktree and branch of each merged head that holds no local work. Squash/rebase merges and head branches kept on the forge are covered; regenerable ignored output (target/, node_modules...) does not keep a worktree, any other ignored file does. The tip is kept in a refs/sync-backup/<machine>/<stamp>/merged/<branch> ref, and materialize no longer brings a pruned branch back unless it gets new commits. New config: sync.prune_merged (default true) and sync.prune_disposable. See docs/prune-merged.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011GZUAKXXztS4Hy4F4sSRkc
This commit is contained in:
19 files changed
+1070
-19
No files matched your search
@@ -345,6 +345,15 @@ pub fn apply_snapshot(
|
||||
|
||||
/// Create worktrees under `root` for remote branches that have none. Returns new paths.
|
||||
pub fn materialize(root: &Path, remote: &str) -> Result<Vec<PathBuf>, GitError> {
|
||||
materialize_except(root, remote, &[])
|
||||
}
|
||||
|
||||
/// Like [`materialize`], leaving out the branches in `skip` (e.g. merged ones that were pruned).
|
||||
pub fn materialize_except(
|
||||
root: &Path,
|
||||
remote: &str,
|
||||
skip: &[String],
|
||||
) -> Result<Vec<PathBuf>, GitError> {
|
||||
let bare = root.join(".bare");
|
||||
let g = Git::new(&bare);
|
||||
let prefix = format!("refs/remotes/{remote}/");
|
||||
@@ -362,7 +371,10 @@ pub fn materialize(root: &Path, remote: &str) -> Result<Vec<PathBuf>, GitError>
|
||||
let Some(branch) = r.strip_prefix(&prefix) else {
|
||||
continue;
|
||||
};
|
||||
if branch == "HEAD" || existing_branches.iter().any(|b| b == branch) {
|
||||
if branch == "HEAD"
|
||||
|| existing_branches.iter().any(|b| b == branch)
|
||||
|| skip.iter().any(|b| b == branch)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let refs: Vec<&str> = taken.iter().map(String::as_str).collect();
|
||||
|
||||
Reference in new issue
Block a user