mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
feat(issue): Add user choice for worktree completion (merge/PR/keep)
- Replace auto-delete cleanup with AskUserQuestion - Options: Merge to main, Create PR, Keep branch - Prevents accidental loss of worktree commits
This commit is contained in:
@@ -32,14 +32,56 @@ cd "${WORKTREE_PATH}"
|
|||||||
- Main working directory stays clean
|
- Main working directory stays clean
|
||||||
- Easy cleanup after execution
|
- Easy cleanup after execution
|
||||||
|
|
||||||
**Cleanup after completion:**
|
**Completion - User Choice:**
|
||||||
```bash
|
|
||||||
# Return to main repo
|
|
||||||
cd -
|
|
||||||
|
|
||||||
# Remove worktree
|
When all solutions are complete, ask user what to do with the worktree branch:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
AskUserQuestion({
|
||||||
|
questions: [{
|
||||||
|
question: "All solutions completed in worktree. What would you like to do with the changes?",
|
||||||
|
header: "Merge",
|
||||||
|
multiSelect: false,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: "Merge to main",
|
||||||
|
description: "Merge worktree branch into main branch and cleanup"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Create PR",
|
||||||
|
description: "Push branch and create a pull request for review"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Keep branch",
|
||||||
|
description: "Keep the branch for manual handling, cleanup worktree only"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Based on user selection:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Return to main repo first
|
||||||
|
MAIN_REPO=$(git worktree list | head -1 | awk '{print $1}')
|
||||||
|
cd "${MAIN_REPO}"
|
||||||
|
|
||||||
|
# Option 1: Merge to main
|
||||||
|
git merge "${WORKTREE_NAME}" --no-ff -m "Merge issue queue execution: ${WORKTREE_NAME}"
|
||||||
git worktree remove "${WORKTREE_PATH}"
|
git worktree remove "${WORKTREE_PATH}"
|
||||||
git branch -d "${WORKTREE_NAME}"
|
git branch -d "${WORKTREE_NAME}"
|
||||||
|
|
||||||
|
# Option 2: Create PR
|
||||||
|
git push -u origin "${WORKTREE_NAME}"
|
||||||
|
gh pr create --title "Issue Queue: ${WORKTREE_NAME}" --body "Automated issue queue execution"
|
||||||
|
git worktree remove "${WORKTREE_PATH}"
|
||||||
|
# Branch kept on remote
|
||||||
|
|
||||||
|
# Option 3: Keep branch
|
||||||
|
git worktree remove "${WORKTREE_PATH}"
|
||||||
|
# Branch kept locally for manual handling
|
||||||
|
echo "Branch '${WORKTREE_NAME}' kept. Merge manually when ready."
|
||||||
```
|
```
|
||||||
|
|
||||||
## Execution Flow
|
## Execution Flow
|
||||||
@@ -326,6 +368,8 @@ ccw issue next
|
|||||||
|
|
||||||
When `ccw issue next` returns `{ "status": "empty" }`:
|
When `ccw issue next` returns `{ "status": "empty" }`:
|
||||||
|
|
||||||
|
**If running in worktree mode**: Prompt user for merge/PR/keep choice (see "Completion - User Choice" above) before outputting summary.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
## Issue Queue Execution Complete
|
## Issue Queue Execution Complete
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user