Skip to content

[luv-198] fix: skip no-conflicts policy when no OPEN PR exists#198

Merged
NiveditJain merged 1 commit into
mainfrom
luv-198
Apr 27, 2026
Merged

[luv-198] fix: skip no-conflicts policy when no OPEN PR exists#198
NiveditJain merged 1 commit into
mainfrom
luv-198

Conversation

@NiveditJain

Copy link
Copy Markdown
Member

Summary

  • require-no-conflicts-before-stop used to run its local git merge-tree probe (Layer 1) unconditionally, so a branch with no PR on GitHub — or only a closed/merged PR — could still receive a deny that referenced a PR URL the user never created.
  • Promoted the gh + PR-state precheck above Layer 1: when gh is unavailable, no PR exists, or pr.state !== "OPEN", the policy short-circuits to allow and never runs Layer 1. Layer 2 reuses the pr already fetched in the precheck — no second gh pr view call.
  • Per user direction: when gh is not installed we skip the entire policy (without gh we cannot confirm a PR exists).

Test plan

  • bun run test:run — 991 unit tests pass
  • bun run test:e2e — 207 e2e tests pass
  • bunx tsc --noEmit — clean
  • bun run lint — only a pre-existing unrelated warning
  • New unit tests assert Layer 1 is not invoked (using mergeTreeStatus: 1) when gh is missing / no PR / PR is CLOSED
  • Manual repro: check out a branch with no PR on GitHub, trigger the Stop hook, confirm the policy now allows with "No pull request found for branch, skipping conflict check." and emits no URL

🤖 Generated with Claude Code

…exists

The policy used to run its local git merge-tree probe (Layer 1)
unconditionally, so a branch with no PR on GitHub — or only a closed/merged
one — could still receive a deny referencing a PR URL the user never
created. Promote the gh + PR-state precheck above Layer 1 so the policy
short-circuits to allow whenever there is no confirmable OPEN merge target,
and reuse the fetched pr in Layer 2 to avoid a second gh round-trip.

When gh CLI is unavailable, the entire policy is skipped (per user
direction) — without gh we cannot confirm a PR exists.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@NiveditJain has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 2 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 51fa0a64-30a7-4be3-b3e7-f23163a38fd2

📥 Commits

Reviewing files that changed from the base of the PR and between 7081187 and de0e96f.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • __tests__/hooks/builtin-policies.test.ts
  • docs/built-in-policies.mdx
  • src/hooks/builtin-policies.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch luv-198

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@NiveditJain NiveditJain merged commit addbcb2 into main Apr 27, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant