mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 12:40:44 +00:00
fix(review): default remote for PR numbers + fork-aware autofix push
1. Pure integer PR numbers default to origin (no URL-based remote matching available). URL-based PRs use the matched remote. 2. Autofix push uses matched remote instead of hardcoded origin. Push failure is expected for fork PRs where user lacks push access — handled gracefully with informative message. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f357517dd2
commit
cb359dc996
1 changed files with 2 additions and 2 deletions
|
|
@ -40,7 +40,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> 2>/dev/null || true`. This ensures a fresh start.
|
||||
2. Fetch the PR branch into a unique local ref: `git fetch <remote> pull/<number>/head:qwen-review/pr-<number>` where `<remote>` is the matched remote from Step 1 (usually `origin`, but could be `upstream` for fork-based workflows). 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.
|
||||
2. Fetch the PR branch into a unique local ref: `git fetch <remote> pull/<number>/head:qwen-review/pr-<number>` where `<remote>` is the matched remote from the URL-based detection above, or `origin` by default for pure integer PR numbers. 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.
|
||||
5. All subsequent steps (linting, agents, build/test, autofix) operate in this worktree directory, not the user's working tree. Cache and reports (Step 10) are written to the **main project directory**, not the worktree.
|
||||
|
|
@ -369,7 +369,7 @@ If there are **Critical** or **Suggestion** findings with clear, unambiguous fix
|
|||
**Important**:
|
||||
|
||||
- Do NOT auto-fix without user confirmation. Do NOT auto-fix findings marked as "Nice to have" or low-confidence findings.
|
||||
- If reviewing a PR (worktree mode), autofix modifies files in the **worktree**, not the user's working tree. After applying fixes, commit and push from the worktree: `cd <worktree-path> && git add <fixed-files> && git commit -m "fix: apply auto-fixes from /review" && git push origin HEAD:<remote-branch-name>` (use the remote branch name obtained in Step 1). Inform the user: "Auto-fixes committed and pushed to the PR branch." If the commit or push fails, inform the user: "Auto-fix commit/push failed. The fixes remain in the worktree at `<worktree-path>`. You can inspect, commit, and push manually." Step 9 (PR comments) may still proceed, but **skip Step 11 worktree cleanup** to preserve the uncommitted fixes for manual recovery.
|
||||
- If reviewing a PR (worktree mode), autofix modifies files in the **worktree**, not the user's working tree. After applying fixes, commit from the worktree: `cd <worktree-path> && git add <fixed-files> && git commit -m "fix: apply auto-fixes from /review"`. Then attempt to push: `git push <remote> HEAD:<remote-branch-name>` (use the remote and branch name from Step 1). **Note**: push may fail if the PR is from a fork and the user doesn't have push access to the source repo — this is expected. Inform the user of the outcome: if push succeeds → "Auto-fixes committed and pushed to the PR branch." If push fails → "Auto-fix committed locally but push failed (you may not have push access to this repo). The commit is in the worktree at `<worktree-path>`. You can push manually or create a new PR." Step 9 (PR comments) may still proceed, but **skip Step 11 worktree cleanup** to preserve the commit for manual recovery.
|
||||
|
||||
## Step 9: Post PR inline comments (only if `--comment` flag was set)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue