Skip to content

Commit c67ec1b

Browse files
committed
use rulesets in the rust repo
1 parent d134d4c commit c67ec1b

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,5 @@ enable-rulesets-repos = [
8787
"rust-lang/cargo",
8888
"rust-lang/crates.io",
8989
"rust-lang/rustfmt",
90+
"rust-lang/rust",
9091
]

repos/rust-lang/rust.toml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,61 +30,92 @@ triage = "write"
3030
[[branch-protections]]
3131
pattern = "main"
3232
allowed-merge-apps = ["bors"]
33+
prevent-update = true
3334

3435
[[branch-protections]]
36+
name = "stable"
3537
pattern = "stable"
36-
allowed-merge-apps = ["bors"]
38+
allowed-merge-apps = ["bors", "promote-release"]
39+
prevent-update = true
40+
41+
[[branch-protections]]
42+
name = "stable - force-pushes"
43+
pattern = "stable"
44+
allowed-merge-apps = ["promote-release"]
45+
prevent-update = true
46+
prevent-force-push = false
47+
3748

3849
[[branch-protections]]
50+
name = "beta"
3951
pattern = "beta"
40-
allowed-merge-apps = ["bors"]
52+
allowed-merge-apps = ["bors", "promote-release"]
53+
prevent-update = true
54+
55+
[[branch-protections]]
56+
name = "beta - force-pushes"
57+
pattern = "beta"
58+
allowed-merge-apps = ["promote-release"]
59+
prevent-update = true
4160

4261
[[branch-protections]]
4362
pattern = "*"
63+
allowed-merge-apps = ["promote-release"]
64+
prevent-deletion = false
65+
prevent-update = true
4466

4567
[[branch-protections]]
4668
pattern = "*/**/*"
4769
pr-required = false
70+
prevent-update = true
71+
prevent-deletion = false
4872

4973
[[branch-protections]]
5074
pattern = "cargo_update"
5175
pr-required = false
76+
prevent-deletion = false
5277

5378
# Required for running try builds created by bors.
5479
# Must support force-pushes.
5580
[[branch-protections]]
5681
pattern = "automation/bors/try"
5782
allowed-merge-apps = ["bors"]
83+
prevent-update = true
5884

5985
# Required for running try builds created by bors.
6086
# Must support force-pushes.
6187
[[branch-protections]]
6288
pattern = "automation/bors/try-merge"
6389
allowed-merge-apps = ["bors"]
90+
prevent-update = true
6491

6592
# Required for running auto builds created by bors.
6693
# Must support force-pushes.
6794
[[branch-protections]]
6895
pattern = "automation/bors/auto"
6996
allowed-merge-apps = ["bors"]
97+
prevent-update = true
7098

7199
# Required for running auto builds created by bors.
72100
# Must support force-pushes.
73101
[[branch-protections]]
74102
pattern = "automation/bors/auto-merge"
75103
allowed-merge-apps = ["bors"]
104+
prevent-update = true
76105

77106
# Required for unrolled PR builds created by perfbot.
78107
# Must support force-pushes.
79108
[[branch-protections]]
80109
pattern = "try-perf"
81110
allowed-merge-apps = ["rust-timer"]
111+
prevent-update = true
82112

83113
# Required for unrolled PR builds created by perfbot.
84114
# Must support force-pushes.
85115
[[branch-protections]]
86116
pattern = "perf-tmp"
87117
allowed-merge-apps = ["rust-timer"]
118+
prevent-update = true
88119

89120
[environments.bors]
90121
branches = ["automation/bors/auto", "automation/bors/try", "try-perf"]

src/validate.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,12 +1150,21 @@ fn validate_branch_protections(data: &Data, errors: &mut Vec<String>) {
11501150

11511151
wrapper(data.repos(), errors, |repo, _| {
11521152
let bors_configured = repo.bots.iter().any(|b| matches!(b, Bot::Bors));
1153-
let mut patterns = HashSet::new();
1153+
let mut pattern_counts = HashMap::new();
11541154

11551155
for protection in &repo.branch_protections {
1156-
if !patterns.insert((protection.target, &protection.pattern)) {
1156+
*pattern_counts
1157+
.entry((protection.target, protection.pattern.as_str()))
1158+
.or_insert(0usize) += 1;
1159+
}
1160+
1161+
for protection in &repo.branch_protections {
1162+
let key = (protection.target, protection.pattern.as_str());
1163+
if pattern_counts.get(&key).copied().unwrap_or_default() > 1
1164+
&& protection.name.is_none()
1165+
{
11571166
bail!(
1158-
r#"repo '{}' uses multiple {:?} protections with the pattern `{}`"#,
1167+
r#"repo '{}' uses multiple {:?} protections with the pattern `{}`; when multiple protections share the same target and pattern, each protection must specify `name`"#,
11591168
repo.name,
11601169
protection.target,
11611170
protection.pattern,

0 commit comments

Comments
 (0)