fix(review): safe branch cleanup + cross-repo agent count

- git branch -D: add 2>/dev/null || true to both cleanup sites
  (Step 1 stale cleanup + Step 11) to prevent abort if ref missing
- Cross-repo doc: clarify Agents 1-4 only (Agent 5 build/test
  requires local codebase, not available in cross-repo mode)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
wenshao 2026-04-07 05:02:13 +08:00
parent 6596362342
commit 720796e699
2 changed files with 11 additions and 11 deletions

View file

@ -120,15 +120,15 @@ You can review PRs from other repositories by passing the full URL:
This runs in **lightweight mode** — no worktree, no linter, no build/test, no autofix. The review is based on the diff text only (fetched via GitHub API). PR comments can still be posted if you have write access.
| Capability | Same-repo | Cross-repo |
| ---------------------------------------------- | --------- | ----------------------------- |
| LLM review (5 agents + verify + reverse audit) | ✅ | ✅ |
| Deterministic analysis (linter/typecheck) | ✅ | ❌ |
| Build & test | ✅ | ❌ |
| Cross-file impact analysis | ✅ | ❌ |
| Autofix | ✅ | ❌ |
| PR inline comments | ✅ | ✅ (if you have write access) |
| Incremental review cache | ✅ | ❌ |
| Capability | Same-repo | Cross-repo |
| ------------------------------------------------ | --------- | ----------------------------- |
| LLM review (Agents 1-4 + verify + reverse audit) | ✅ | ✅ |
| Agent 5: Build & test | ✅ | ❌ (no local codebase) |
| Deterministic analysis (linter/typecheck) | ✅ | ❌ |
| Cross-file impact analysis | ✅ | ❌ |
| Autofix | ✅ | ❌ |
| PR inline comments | ✅ | ✅ (if you have write access) |
| Incremental review cache | ✅ | ❌ |
## PR Inline Comments

View file

@ -33,7 +33,7 @@ Based on the remaining arguments:
- **PR number or same-repo URL** (e.g., `123` or a URL whose owner/repo matches the current repo — cross-repo URLs are handled by the lightweight mode above):
- **Create an ephemeral worktree** to avoid modifying the user's working tree. This eliminates all stash/checkout/restore complexity:
1. **Clean up stale worktree** from a previously interrupted review (if any): if `.qwen/tmp/review-pr-<number>` exists, remove it with `git worktree remove .qwen/tmp/review-pr-<number> --force` and delete the stale ref `git branch -D qwen-review/pr-<number>` if it exists. This ensures a fresh start.
1. **Clean up stale worktree** from a previously interrupted review (if any): if `.qwen/tmp/review-pr-<number>` exists, remove it with `git worktree remove .qwen/tmp/review-pr-<number> --force` and delete the stale ref `git branch -D qwen-review/pr-<number> 2>/dev/null || true`. This ensures a fresh start.
2. Fetch the PR branch into a unique local ref: `git fetch origin pull/<number>/head:qwen-review/pr-<number>` (do NOT use `gh pr checkout` — it modifies the current working tree). If fetch fails (auth, network, PR doesn't exist), inform the user and stop.
3. Get the PR's remote branch name for later push: `gh pr view <number> --json headRefName --jq '.headRefName'`. If this fails, inform the user and stop.
4. Create a temporary worktree: `git worktree add .qwen/tmp/review-pr-<number> qwen-review/pr-<number>`. If this fails, inform the user and stop.
@ -483,7 +483,7 @@ Remove all temp files (`/tmp/qwen-review-{target}-context.md`, `/tmp/qwen-review
If a PR worktree was created in Step 1, remove it and its local ref:
1. `git worktree remove .qwen/tmp/review-pr-<number> --force` (the `--force` flag handles cases where autofix left uncommitted changes)
2. `git branch -D qwen-review/pr-<number>` (clean up the local ref created during fetch)
2. `git branch -D qwen-review/pr-<number> 2>/dev/null || true` (clean up the local ref; ignore errors if already deleted)
This step runs **after** Step 9 because Step 9 may still need the worktree for reading file contents when composing inline comments.