feat(merge): delete source branch on merge — repo policy + labctl pr merge flags #130
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/coding-lab#130
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What to build
A repo-level
delete_branch_on_mergepolicy (default off) plus per-call overrides--delete-branch/--keep-branchonlabctl pr merge, so that merging a PR also deletes its remote head branch on the forge. Today nothing ever deletes the forge-side branch:gitx.DeleteBranchis a localgit branch -Din the bare mirror only, and the Forgejo client explicitly omitsdelete_branch_after_merge— every merged PR leaves a dead remote branch behind.End-to-end behavior:
delete_branch_on_merge(default off), editable in RepoSettings and PATCH-able viaRepoUpdate.labctl pr merge <n>gains mutually-exclusive--delete-branch/--keep-branch; the flag is threaded as an optional tri-state field onPOST /agent/v1/prs/{n}/mergeand overrides the repo policy for that call. No flag → policy applies.--delete-branchon an unmanaged (human) head is a refused no-op with a notice in the response; the merge itself still succeeds. Mirrors theManagedBranchscoping the sweep already uses (internal/gitx/worktree.go:187).delete_branch_after_merge: truein the merge body when deletion resolves on; GitHub issues an explicit ref delete after merge; builtin changes nothing (its head lives in the local bare repo where the run's worktree may still be checked out — the existing guarded teardown already deletes clean+merged branches).Acceptance criteria
delete_branch_on_mergeexists, defaults off, surfaced in RepoSettings UI and PATCH-ablelabctl pr mergeaccepts--delete-branch/--keep-branch(mutually exclusive), threaded through the agent API; no flag → repo policy decides--delete-branchon an unmanaged head → merge succeeds, deletion refused with a noticedelete_branch_after_mergein the merge request; GitHub deletes the ref after merge; builtin merge behavior unchangedBlocked by
None - can start immediately