Teach merged cleanup to discover non-canonical local worktree names #528

Closed
opened 2026-07-08 04:01:56 -05:00 by jcwalker3 · 0 comments
Owner

Problem:
During PR #512 / issue #510 cleanup, gitea_reconcile_merged_cleanups could not own/remove the local worktree branches/issue-510-workspace-binding-isolation because its path derivation expected a feat-issue-* style name. The worktree was clean, matched the merged feature branch, and issue #510 was closed, but cleanup remained blocked by naming mismatch.

Required behavior:

  • Merged cleanup should discover local worktrees by branch/ref/HEAD relationship, not only by derived path naming.
  • It should identify clean worktrees whose branch matches the merged source branch.
  • It should still fail closed for dirty, detached, ambiguous, or unrelated worktrees.
  • It should report why a worktree is or is not safe to remove.
  • It must not touch foreign stashes or unrelated worktrees.

Acceptance criteria:

  1. Add discovery of local worktrees by source branch/ref.
  2. Support cleanup of clean merged worktrees even when path names differ from the derived convention.
  3. Preserve fail-closed behavior for dirty or ambiguous worktrees.
  4. Add tests for canonical and non-canonical worktree path names.
  5. Update cleanup report output to list matched-by-path vs matched-by-branch.
Problem: During PR #512 / issue #510 cleanup, gitea_reconcile_merged_cleanups could not own/remove the local worktree branches/issue-510-workspace-binding-isolation because its path derivation expected a feat-issue-* style name. The worktree was clean, matched the merged feature branch, and issue #510 was closed, but cleanup remained blocked by naming mismatch. Required behavior: - Merged cleanup should discover local worktrees by branch/ref/HEAD relationship, not only by derived path naming. - It should identify clean worktrees whose branch matches the merged source branch. - It should still fail closed for dirty, detached, ambiguous, or unrelated worktrees. - It should report why a worktree is or is not safe to remove. - It must not touch foreign stashes or unrelated worktrees. Acceptance criteria: 1. Add discovery of local worktrees by source branch/ref. 2. Support cleanup of clean merged worktrees even when path names differ from the derived convention. 3. Preserve fail-closed behavior for dirty or ambiguous worktrees. 4. Add tests for canonical and non-canonical worktree path names. 5. Update cleanup report output to list matched-by-path vs matched-by-branch.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Scaled-Tech-Consulting/Gitea-Tools#528