The Rules feature allows you to define how pull requests are scored based on customisable conditions. With Rules,
you can tailor PullRule’s scoring system to reflect your own code quality, review process, and team standards-using
a flexible, condition-based approach.
What are rules?
A rulle is a collection of conditions that determine how points are added to or subtracted from a pull request’s score.
Each rule can contain one or more conditions, and PullRule supports multiple rules within your organisation. These rules
evaluate pull requests as they come in or are updated.
Rules are executed on every new pull request and whenever a pull request is modified in the repository.
Autonomy of a condition
Each condition in a rule follows an “if this, then that” strucute.
Example:
If number of changed files
is greather than 50,
then subtract 5 points
from the pull request score.
This allows you to design scoring strategies that reward or penalise PRs based on specific traits or conventions.
Available conditions
Each condition evaluates a specific attribute of the pull request. Here are the supported conditions and their
operators:
Author condition | Operator(s) |
---|
Author name | Equals, Not equals, Matches, Starts with, Ends with, Contains |
Commit condition | Operator(s) |
---|
Commit body | Any matches, Any equals |
File condition | Operator(s) |
---|
Filename | Any equals |
State | Any equals |
Added lines | Any equals |
Deleted lines | Any equals |
Changed lines | Any equals |
Pull request condition | Operator(s) |
---|
Number of changed files | Equals, Not equals, Greater than, Greater than or equals, Less than, Less than or equals |
Deleted lines | Equals, Not equals, Greater than, Greater than or equals, Less than, Less than or equals |
Added lines | Equals, Not equals, Greater than, Greater than or equals, Less than, Less than or equals |
Number of comments | Equals, Not equals, Greater than, Greater than or equals, Less than, Less than or equals |
Pull request title | Matches, Starts with, Ends with, Contains |
Pull request description | Matches, Starts with, Ends with, Contains |
Each condition must specify an outcome:
- Add points (reward good practices)
- Subtract points (penalise undesirable patterns)
You decide how many points are applied when the condition is met. The final score of a pull request is the sum of all rule-based point adjustments.
Building rules
You can add as many conditions as you want to a single rule or create multiple rules to capture different scoring
strategies (e.g. size control, commit hygiene, title formant enforcement, etc.).
Rules are evaluated independently, and their outcomes are cumulative. This means that if multiple rules apply to a pull request, the points from each rule are summed to produce the final score.
Selecting when rules are applied
You may choose to apply rules each time a pull request is created or updated, or as an example only when a pull request is merged.
This flexibility allows you to control when the rules are enforced and how they impact the pull request workflow.
In the rule settings, you can select the appropriate “stage” for the rule to apply. These stages include:
- Every change: The rule is evaluated on every new pull request and whenever a pull request is modified.
- On initial index: The rule is evaluated only when a pull request is created.
- On manual trigger: The rule is evaluated only when you manually trigger it through the API.
- On merge: The rule is evaluated only when a pull request is merged.