Also count reviews required by org-level rulesets - #106
Merged
Merged
Conversation
`getRequiredApprovingReviewCount` only read classic `branchProtectionRule.requiredApprovingReviewCount`, so a repo that enforces its review requirement via a repository- or org-level Ruleset instead of (or in addition to) classic branch protection was treated as requiring 0 approving reviews. `Ref.rules` returns "a list of rules from active Repository and Organization rulesets that apply to this ref", so query it alongside `branchProtectionRule` and take the higher of the two required counts - satisfying the higher requirement independently also satisfies the lower one, so the two aren't summed. Only rules of type `PULL_REQUEST` carry a review count; other rule types are skipped. Request `pageInfo.hasNextPage` on the rules connection and fail loudly if there are more than 100 active rules, rather than silently under-counting rules past the first page. Fixes Expensify/Expensify#668528
Contributor
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Contributor
Author
|
@MelvinBot review |
roryabraham
marked this pull request as ready for review
September 7, 2026 23:01
rafecolton
approved these changes
Sep 12, 2026
rafecolton
left a comment
Member
There was a problem hiding this comment.
LGTM. Let's test on the test repo once it's merged?
Member
|
Tested in https://github.com/Expensify/test/pull/1039 and tl;dr it worked great! 🎉
My only feedback is it might be handy to log whether the review rule was from a branch setting or ruleset (NAB) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Details
getRequiredApprovingReviewCount(used byverifyPeerReviewto decide how many independent approvals a PR needs before it can merge) only read the review count from classicbranchProtectionRule.requiredApprovingReviewCount. It never checked reviews required by org-level (or repo-level) Rulesets, so a repo/branch that enforces its review requirement exclusively through a Ruleset was treated as requiring 0 approving reviews, letting the peer-review check pass with no review at all.Note that this a hypothetical problem for now. I'm not aware of any repos that rely on repo-level or org-level rulesets for requiring reviews rather than traditional branch protection.
Related Issues
$ https://github.com/Expensify/Expensify/issues/668528
Manual Tests
n/a - automated tests only.
Linked PRs
N/A