Add iw finish command: merge final PR and remove worktree #249
Labels
No labels
agent-ready
bug
contract
documentation
duplicate
enhancement
good first issue
help wanted
invalid
needs-human
needs-input
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
iterative-works/iw-cli#249
Loading…
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?
Problem
After all implementation phases are complete, the developer has a feature branch with a PR to main. Closing out the issue requires multiple manual steps across two worktrees:
There's no single command to do this. The `phase-pr` command only creates PRs from phase sub-branches to the feature branch — it never targets main. The `rm` command removes the worktree but doesn't check or merge any PR.
Proposed Solution
Add `iw finish ` — run from the main worktree to merge the final PR and clean up.
Behavior
Flags
Safety Checks
Error Cases
Acceptance Criteria
Notes
See `project-management/issues/<THIS_ISSUE>/analysis.md` for implementation notes.
Intake: needs-input
The goal of the command is clear, but four choices conflict with the current repository or with open issue #174, and only a human can make them.
1. Must
iw finishmerge the final PR with a squash or with a merge commit?The issue says "Squash-merge the PR". But each final PR on
mainmerges with a merge commit, for example33e14e5f"Merge pull request 'IW-681: …' (#798)". A squash makes all the phase commits of an issue into one commit. The forge code has the two merge types:mergeSquashAndDeleteandmergeWithDelete(ForgeGateway.scala L75-L105).mainnow. The phase history stays.main.Recommended: a): it does what the project does now, and the phase history stays.
2. Which forges must
iw finishsupport?The acceptance criteria name only GitHub and GitLab. This project is on Forgejo, and the code that merges PRs already supports Forgejo, GitHub and GitLab.
Recommended: a): if the command does not support Forgejo, this project cannot use it.
3. What must
iw finishdo with the review-state card after the merge?The issue asks for a new status,
finished. The schema does not have it. The known statuses end atall_complete(ReviewState.scala L83-L84). Open issue #706 decides wheniw rmdeletes a card ("2: b", delete it atall_complete). A follow-up question on #706 asks if the PR must also be merged first.iw rm. There is no change to the schema.finishedbefore the worktree is removed. This adds a status to the schema. The schema is in kanon too, so kanon must change.Recommended: a): it adds no status, and it does not make a second card rule next to the one in #706.
4. What do we do with open issue #174, "Add 'merge' command to complete issue workflow from main repo"?
#174 asks for the same command with the name
iw merge. It also asks to close the tracker issue, and for--dry-run,--keep-worktreeand--no-squash. This issue (#249) does not ask for these. If we implement both issues, we get two commands that do the same work.iw finish, then close #174. One command. The work is larger.iw finish.Recommended: c): it makes the scope of #249 no larger, and it loses none of the items in #174.
Answer in a comment on this issue, per number, for example "1: a", or in your own words; intake reads it on its next iteration.