Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/toml-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ require-up-to-date-branches = false
# merging into this branch require another review.
# (optional - default `false`)
dismiss-stale-review = false
# Whether all PR conversations must be resolved before merging.
# (optional - default `false`)
require-conversation-resolution = false
# Is a PR required when making changes to this branch?
# (optional - default `true`)
pr-required = true
Expand Down
2 changes: 1 addition & 1 deletion repos/rust-lang/blog.rust-lang.org.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ci-checks = [
"lint",
"build",
]
require-conversation-resolution = true

[environments.github-pages]
branches = ["main"]

1 change: 1 addition & 0 deletions repos/rust-lang/docs.rs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ docs-rs-reviewers = 'write'
[[branch-protections]]
pattern = 'main'
required-approvals = 0
require-conversation-resolution = true

[environments.production]
branches = ["main"]
Expand Down
1 change: 1 addition & 0 deletions repos/rust-lang/promote-release.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ ci-checks = [
"Test",
]
required-approvals = 0
require-conversation-resolution = true
1 change: 1 addition & 0 deletions repos/rust-lang/relnotes.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ ci-checks = [
"build (windows-latest, stable)",
]
required-approvals = 0
require-conversation-resolution = true
2 changes: 1 addition & 1 deletion repos/rust-lang/thorin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ compiler = 'maintain'

[[branch-protections]]
pattern = "main"
require-conversation-resolution = true

[[crates-io]]
crates = ["thorin-dwp", "thorin-dwp-bin"]
Expand All @@ -17,4 +18,3 @@ teams = ["compiler"]

[environments.publish]
branches = ["main"]

2 changes: 2 additions & 0 deletions rust_team_data/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ pub struct BranchProtection {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
pub dismiss_stale_review: bool,
#[serde(default)]
pub require_conversation_resolution: bool,
Copy link
Copy Markdown
Member Author

@marcoieni marcoieni Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In another PR, Kobzol said that adding new fields is not a breaking change for triagebot 👍

pub mode: BranchProtectionMode,
pub allowed_merge_teams: Vec<String>,
pub merge_bots: Vec<MergeBot>,
Expand Down
2 changes: 2 additions & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,8 @@ pub(crate) struct BranchProtection {
#[serde(default)]
pub dismiss_stale_review: bool,
#[serde(default)]
pub require_conversation_resolution: bool,
#[serde(default)]
pub required_approvals: Option<u32>,
#[serde(default = "default_true")]
pub pr_required: bool,
Expand Down
1 change: 1 addition & 0 deletions src/static_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ impl<'a> Generator<'a> {
},
name: b.name.clone(),
dismiss_stale_review: b.dismiss_stale_review,
require_conversation_resolution: b.require_conversation_resolution,
mode: if b.pr_required {
BranchProtectionMode::PrRequired {
ci_checks: b.ci_checks.clone(),
Expand Down
1 change: 1 addition & 0 deletions src/sync/github/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ pub(crate) struct BranchProtection {
pub(crate) is_admin_enforced: bool,
pub(crate) allows_force_pushes: bool,
pub(crate) dismisses_stale_reviews: bool,
pub(crate) requires_conversation_resolution: bool,
pub(crate) requires_strict_status_checks: bool,
#[serde(default, deserialize_with = "nullable")]
pub(crate) required_approving_review_count: u8,
Expand Down
1 change: 1 addition & 0 deletions src/sync/github/api/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ impl GithubRead for GitHubApiRead {
isAdminEnforced,
allowsForcePushes,
dismissesStaleReviews,
requiresConversationResolution,
requiresStrictStatusChecks,
requiredStatusCheckContexts,
requiredApprovingReviewCount,
Expand Down
6 changes: 5 additions & 1 deletion src/sync/github/api/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ impl GitHubWrite {
contexts: &'a [String],
allows_force_pushes: bool,
dismiss_stale: bool,
requires_conversation_resolution: bool,
requires_strict_status_checks: bool,
review_count: u8,
restricts_pushes: bool,
Expand All @@ -430,7 +431,7 @@ impl GitHubWrite {
BranchProtectionOp::UpdateBranchProtection(id) => id,
};
let query = format!("
mutation($id: ID!, $pattern:String!, $contexts: [String!], $allowsForcePushes: Boolean, $dismissStale: Boolean, $requiresStrictStatusChecks: Boolean, $reviewCount: Int, $pushActorIds: [ID!], $restrictsPushes: Boolean, $requiresApprovingReviews: Boolean) {{
mutation($id: ID!, $pattern:String!, $contexts: [String!], $allowsForcePushes: Boolean, $dismissStale: Boolean, $requiresConversationResolution: Boolean, $requiresStrictStatusChecks: Boolean, $reviewCount: Int, $pushActorIds: [ID!], $restrictsPushes: Boolean, $requiresApprovingReviews: Boolean) {{
{mutation_name}(input: {{
{id_field}: $id,
pattern: $pattern,
Expand All @@ -441,6 +442,7 @@ impl GitHubWrite {
allowsForcePushes: $allowsForcePushes,
requiredApprovingReviewCount: $reviewCount,
dismissesStaleReviews: $dismissStale,
requiresConversationResolution: $requiresConversationResolution,
requiresApprovingReviews: $requiresApprovingReviews,
restrictsPushes: $restrictsPushes,
pushActorIds: $pushActorIds
Expand Down Expand Up @@ -478,6 +480,8 @@ impl GitHubWrite {
contexts: &branch_protection.required_status_check_contexts,
allows_force_pushes: branch_protection.allows_force_pushes,
dismiss_stale: branch_protection.dismisses_stale_reviews,
requires_conversation_resolution: branch_protection
.requires_conversation_resolution,
requires_strict_status_checks: branch_protection
.requires_strict_status_checks,
review_count: branch_protection.required_approving_review_count,
Expand Down
10 changes: 9 additions & 1 deletion src/sync/github/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ pub fn construct_branch_protection(
is_admin_enforced: true,
allows_force_pushes: !branch_protection.prevent_force_push,
dismisses_stale_reviews: branch_protection.dismiss_stale_review,
requires_conversation_resolution: branch_protection.require_conversation_resolution,
requires_strict_status_checks: branch_protection.require_up_to_date_branches,
required_approving_review_count,
required_status_check_contexts: checks,
Expand Down Expand Up @@ -1056,7 +1057,8 @@ pub fn construct_ruleset(branch_protection: &rust_team_data::v1::BranchProtectio
require_code_owner_review: REQUIRE_CODE_OWNER_REVIEW_DEFAULT,
require_last_push_approval: REQUIRE_LAST_PUSH_APPROVAL_DEFAULT,
required_approving_review_count: github_int(*required_approvals),
required_review_thread_resolution: REQUIRED_REVIEW_THREAD_RESOLUTION_DEFAULT,
required_review_thread_resolution: branch_protection
.require_conversation_resolution,
},
});
}
Expand Down Expand Up @@ -1815,6 +1817,12 @@ fn log_branch_protection(
new.map(|n| &n.dismisses_stale_reviews),
&mut result,
)?;
log_field(
"Require conversation resolution",
&current.requires_conversation_resolution,
new.map(|n| &n.requires_conversation_resolution),
&mut result,
)?;
log_field(
"Is admin enforced",
&current.is_admin_enforced,
Expand Down
6 changes: 6 additions & 0 deletions src/sync/github/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ async fn repo_create() {
is_admin_enforced: true,
allows_force_pushes: false,
dismisses_stale_reviews: false,
requires_conversation_resolution: false,
requires_strict_status_checks: false,
required_approving_review_count: 1,
required_status_check_contexts: [
Expand Down Expand Up @@ -746,6 +747,7 @@ async fn repo_add_branch_protection() {
is_admin_enforced: true,
allows_force_pushes: false,
dismisses_stale_reviews: false,
requires_conversation_resolution: false,
requires_strict_status_checks: false,
required_approving_review_count: 0,
required_status_check_contexts: [
Expand All @@ -765,6 +767,7 @@ async fn repo_add_branch_protection() {
is_admin_enforced: true,
allows_force_pushes: false,
dismisses_stale_reviews: false,
requires_conversation_resolution: false,
requires_strict_status_checks: false,
required_approving_review_count: 0,
required_status_check_contexts: [],
Expand Down Expand Up @@ -810,6 +813,7 @@ async fn repo_update_branch_protection() {
BranchProtectionMode::PrNotRequired => unreachable!(),
}
protection.dismiss_stale_review = true;
protection.require_conversation_resolution = true;
protection.prevent_force_push = false;
protection.require_up_to_date_branches = true;

Expand Down Expand Up @@ -846,6 +850,7 @@ async fn repo_update_branch_protection() {
is_admin_enforced: true,
allows_force_pushes: false,
dismisses_stale_reviews: false,
requires_conversation_resolution: false,
requires_strict_status_checks: false,
required_approving_review_count: 1,
required_status_check_contexts: [
Expand All @@ -859,6 +864,7 @@ async fn repo_update_branch_protection() {
is_admin_enforced: true,
allows_force_pushes: true,
dismisses_stale_reviews: true,
requires_conversation_resolution: true,
requires_strict_status_checks: true,
required_approving_review_count: 0,
required_status_check_contexts: [
Expand Down
4 changes: 4 additions & 0 deletions src/sync/github/tests/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ pub struct BranchProtectionBuilder {
pub pattern: String,
pub target: ProtectionTarget,
pub dismiss_stale_review: bool,
pub require_conversation_resolution: bool,
pub mode: BranchProtectionMode,
pub allowed_merge_teams: Vec<String>,
pub allowed_merge_apps: Vec<MergeBot>,
Expand Down Expand Up @@ -473,6 +474,7 @@ impl BranchProtectionBuilder {
pattern,
target,
dismiss_stale_review,
require_conversation_resolution,
mode,
allowed_merge_teams,
allowed_merge_apps,
Expand All @@ -493,6 +495,7 @@ impl BranchProtectionBuilder {
pattern,
target,
dismiss_stale_review,
require_conversation_resolution,
mode,
allowed_merge_teams,
allowed_merge_apps,
Expand Down Expand Up @@ -521,6 +524,7 @@ impl BranchProtectionBuilder {
target: ProtectionTarget::default(),
mode,
dismiss_stale_review: false,
require_conversation_resolution: false,
allowed_merge_teams: vec![],
allowed_merge_apps: vec![],
require_up_to_date_branches: false,
Expand Down
2 changes: 2 additions & 0 deletions tests/static-api/_expected/v1/repos.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{
"pattern": "master",
"dismiss_stale_review": false,
"require_conversation_resolution": false,
"mode": {
"pr_required": {
"ci_checks": [
Expand Down Expand Up @@ -58,6 +59,7 @@
{
"pattern": "master",
"dismiss_stale_review": false,
"require_conversation_resolution": false,
"mode": {
"pr_required": {
"ci_checks": [
Expand Down
1 change: 1 addition & 0 deletions tests/static-api/_expected/v1/repos/archived_repo.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"pattern": "master",
"dismiss_stale_review": false,
"require_conversation_resolution": false,
"mode": {
"pr_required": {
"ci_checks": [
Expand Down
1 change: 1 addition & 0 deletions tests/static-api/_expected/v1/repos/some_repo.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
{
"pattern": "master",
"dismiss_stale_review": false,
"require_conversation_resolution": false,
"mode": {
"pr_required": {
"ci_checks": [
Expand Down