Skip to content

feat: Add dismissal_restriction to PullRequestRuleParameters - #4599

Open
benlangfeld wants to merge 1 commit into
google:masterfrom
benlangfeld:dismissal-restriction
Open

benlangfeld wants to merge 1 commit into
google:masterfrom
benlangfeld:dismissal-restriction

Conversation

@benlangfeld

Copy link
Copy Markdown

A ruleset's pull_request rule can restrict who may dismiss a review, the same way a branch protection rule's dismissal_restrictions does. PullRequestRuleParameters stops short of it, so a ruleset that has one round-trips through this client without it: unmarshalling drops the restriction, and marshalling the result back sends a rule that no longer has one.

The REST API accepts and returns it as pull_request.parameters.dismissal_restriction, and describes it as repository-rule-params-dismissal-restriction:

{
  "title": "DismissalRestriction",
  "description": "Specify people, teams, or apps allowed to dismiss pull request reviews.",
  "properties": {
    "allowed_actors": { "type": "array", "items": { "$ref": "#/components/schemas/repository-rule-params-actor" } },
    "enabled": { "type": "boolean" }
  },
  "required": ["enabled"]
}

A live ruleset carries it whether or not it is in use — this is a repository ruleset created without one:

{"type": "pull_request", "parameters": {"dismissal_restriction": {"allowed_actors": [], "enabled": false}, ...}}

enabled is required by the schema, so it is a plain bool; allowed_actors is optional and omitted when empty.

The actor type is its own enum rather than a reuse of BypassActorType, because GitHub documents a different set for this field: User, Team, IntegrationInstallation, RepositoryRole. An app is IntegrationInstallation here and Integration in a bypass actor, so sharing the type would let a value that is valid in one place be written into the other.

Accessors are regenerated. Two round-trip cases are added to TestRepositoryRule: one restricting dismissal to a team and the admin repository role, and one enabling the restriction with no allowed actors, which is how "administrators only" is expressed.

A ruleset's pull_request rule can restrict who may dismiss a review, in
the same way a branch protection rule's dismissal_restrictions does. The
REST API accepts and returns it as pull_request.dismissal_restriction and
describes it in repository-rule-params-dismissal-restriction, but the
parameters struct here stopped short of it, so a ruleset round-tripped
through this client silently loses the restriction.

Actor types are the enum GitHub documents for this field, which is not the
same set as BypassActorType: an app is IntegrationInstallation here and
Integration there.
@benlangfeld
benlangfeld marked this pull request as draft September 29, 2026 00:04
@google-cla

google-cla Bot commented Sep 29, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@codecov

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.59%. Comparing base (48d0a66) to head (aee1387).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4599   +/-   ##
=======================================
  Coverage   98.59%   98.59%           
=======================================
  Files         197      197           
  Lines       18326    18326           
=======================================
  Hits        18068    18068           
  Misses        258      258           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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