Add 'merge' command to complete issue workflow from main repo #174

Open
opened 2026-01-27 14:34:21 +00:00 by mprihoda · 0 comments
mprihoda commented 2026-01-27 14:34:21 +00:00 (Migrated from github.com)

Summary

Add an iw merge <issue-id> command that can be run from the main repository to complete the full issue lifecycle - merging the PR, closing the issue, and cleaning up the worktree.

Problem

Currently, after an issue implementation is complete and the final PR is ready:

  1. We manually merge the PR (via GitHub or gh pr merge)
  2. We manually close the issue (if not auto-closed)
  3. We need to remember to clean up the worktree with iw rm

This is error-prone and leaves orphaned worktrees if we forget the cleanup step.

Proposed Solution

A single command that handles the full completion flow:

# From main repo
iw merge IW-100

What it should do:

  1. Find the PR for the issue branch (e.g., IW-100 → main)
  2. Verify PR is approved/ready to merge
  3. Merge the PR (squash by default, with flag for merge commit)
  4. Close the issue in the tracker (if not auto-closed by PR)
  5. Remove the worktree by calling existing rm command logic
  6. Optionally delete the remote branch

Flags:

  • --no-squash - Use merge commit instead of squash
  • --keep-worktree - Don't remove the worktree after merge
  • --dry-run - Show what would happen without doing it

Example Flow

$ iw merge IW-100
✓ Found PR #173: fix(dashboard): Use Phase Index as source of truth
✓ PR is approved and ready to merge
✓ Merged PR #173 to main (squash)
✓ Issue IW-100 closed
✓ Removed worktree at /home/user/projects/iw-cli-IW-100
✓ Deleted remote branch IW-100

🎉 Issue IW-100 complete!

Acceptance Criteria

  • Command merges the PR associated with the issue
  • Command closes the issue if not auto-closed
  • Command removes the worktree (reuses rm command logic)
  • Works from the main repository (not from within the worktree)
  • Handles errors gracefully (PR not ready, conflicts, etc.)
  • Supports dry-run mode

Notes

  • Should integrate with existing rm command for worktree cleanup
  • Consider checking for uncommitted changes in worktree before removal
  • May need to handle case where worktree doesn't exist (already cleaned up)
## Summary Add an `iw merge <issue-id>` command that can be run from the main repository to complete the full issue lifecycle - merging the PR, closing the issue, and cleaning up the worktree. ## Problem Currently, after an issue implementation is complete and the final PR is ready: 1. We manually merge the PR (via GitHub or `gh pr merge`) 2. We manually close the issue (if not auto-closed) 3. We need to remember to clean up the worktree with `iw rm` This is error-prone and leaves orphaned worktrees if we forget the cleanup step. ## Proposed Solution A single command that handles the full completion flow: ```bash # From main repo iw merge IW-100 ``` **What it should do:** 1. Find the PR for the issue branch (e.g., `IW-100` → main) 2. Verify PR is approved/ready to merge 3. Merge the PR (squash by default, with flag for merge commit) 4. Close the issue in the tracker (if not auto-closed by PR) 5. Remove the worktree by calling existing `rm` command logic 6. Optionally delete the remote branch **Flags:** - `--no-squash` - Use merge commit instead of squash - `--keep-worktree` - Don't remove the worktree after merge - `--dry-run` - Show what would happen without doing it ## Example Flow ```bash $ iw merge IW-100 ✓ Found PR #173: fix(dashboard): Use Phase Index as source of truth ✓ PR is approved and ready to merge ✓ Merged PR #173 to main (squash) ✓ Issue IW-100 closed ✓ Removed worktree at /home/user/projects/iw-cli-IW-100 ✓ Deleted remote branch IW-100 🎉 Issue IW-100 complete! ``` ## Acceptance Criteria - [ ] Command merges the PR associated with the issue - [ ] Command closes the issue if not auto-closed - [ ] Command removes the worktree (reuses `rm` command logic) - [ ] Works from the main repository (not from within the worktree) - [ ] Handles errors gracefully (PR not ready, conflicts, etc.) - [ ] Supports dry-run mode ## Notes - Should integrate with existing `rm` command for worktree cleanup - Consider checking for uncommitted changes in worktree before removal - May need to handle case where worktree doesn't exist (already cleaned up)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
iterative-works/iw-cli#174
No description provided.