Skip to content

Commit e61410a

Browse files
committed
use rulesets by default
1 parent d12b9d8 commit e61410a

File tree

7 files changed

+264
-190
lines changed

7 files changed

+264
-190
lines changed

config.toml

Lines changed: 2 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -83,89 +83,6 @@ members-without-zulip-id = [
8383
"rust-timer",
8484
]
8585

86-
enable-rulesets-repos = [
87-
"rust-analyzer/expect-test",
88-
"rust-lang-nursery/rust-toolstate",
89-
"rust-lang/annotate-snippets-rs",
90-
"rust-lang/arewewebyet",
91-
"rust-lang/async-fundamentals-initiative",
92-
"rust-lang/backtrace-rs",
93-
"rust-lang/beyond-refs",
94-
"rust-lang/blog.rust-lang.org",
95-
"rust-lang/book",
96-
"rust-lang/bors",
97-
"rust-lang/calendar-generation",
98-
"rust-lang/calendar",
99-
"rust-lang/cargo-bisect-rustc",
100-
"rust-lang/cargo",
101-
"rust-lang/cc-rs",
102-
"rust-lang/ci-mirrors",
103-
"rust-lang/cmake-rs",
104-
"rust-lang/compiler-builtins",
105-
"rust-lang/compiler-team",
106-
"rust-lang/crater",
107-
"rust-lang/crates_io_og_image",
108-
"rust-lang/crates-build-env",
109-
"rust-lang/crates-io-auth-action",
110-
"rust-lang/crates.io",
111-
"rust-lang/crates.io-index-archive",
112-
"rust-lang/crates.io-index",
113-
"rust-lang/docs.rs",
114-
"rust-lang/edition-guide",
115-
"rust-lang/ena",
116-
"rust-lang/enzyme",
117-
"rust-lang/flate2-rs",
118-
"rust-lang/fls",
119-
"rust-lang/futures-rs",
120-
"rust-lang/gha-self-hosted",
121-
"rust-lang/git2-rs",
122-
"rust-lang/gll",
123-
"rust-lang/glob",
124-
"rust-lang/hashbrown",
125-
"rust-lang/impl-trait-utils",
126-
"rust-lang/infra-smoke-tests",
127-
"rust-lang/josh-sync",
128-
"rust-lang/leadership-council",
129-
"rust-lang/libc",
130-
"rust-lang/llvm-project",
131-
"rust-lang/mdBook",
132-
"rust-lang/measureme",
133-
"rust-lang/miri",
134-
"rust-lang/miri-test-libstd",
135-
"rust-lang/nomicon",
136-
"rust-lang/odht",
137-
"rust-lang/portable-simd",
138-
"rust-lang/project-stable-mir",
139-
"rust-lang/project-exploit-mitigations",
140-
"rust-lang/promote-release",
141-
"rust-lang/reference",
142-
"rust-lang/relnotes",
143-
"rust-lang/rfcs",
144-
"rust-lang/rust-analyzer",
145-
"rust-lang/rust-bindgen",
146-
"rust-lang/rust-clippy",
147-
"rust-lang/rust-forge",
148-
"rust-lang/rust-log-analyzer",
149-
"rust-lang/rust-playground",
150-
"rust-lang/rustc_codegen_c",
151-
"rust-lang/rustc_codegen_gcc",
152-
"rust-lang/rustc-demangle",
153-
"rust-lang/rustc-dev-guide",
154-
"rust-lang/rustc-hash",
155-
"rust-lang/rustc-perf",
156-
"rust-lang/rustc-stable-hash",
157-
"rust-lang/rustfmt",
158-
"rust-lang/rustup",
159-
"rust-lang/simpleinfra",
160-
"rust-lang/socket2",
161-
"rust-lang/staging.crates.io-index",
162-
"rust-lang/std-dev-guide",
163-
"rust-lang/stdarch",
164-
"rust-lang/team",
165-
"rust-lang/this-week-in-rust",
166-
"rust-lang/thorin",
167-
"rust-lang/triagebot",
168-
"rust-lang/wg-async",
169-
"rust-lang/wg-macros",
170-
"rust-lang/www.rust-lang.org",
86+
disable-rulesets-repos = [
87+
"rust-lang/rust",
17188
]

src/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl Data {
242242
Ok(sync::Config {
243243
special_org_members,
244244
independent_github_orgs: self.config.independent_github_orgs().clone(),
245-
enable_rulesets_repos: self.config.enable_rulesets_repos().clone(),
245+
disable_rulesets_repos: self.config.disable_rulesets_repos().clone(),
246246
})
247247
}
248248
}

src/schema.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) struct Config {
1717
special_org_members: BTreeSet<String>,
1818
members_without_zulip_id: BTreeSet<String>,
1919
#[serde(default)]
20-
enable_rulesets_repos: BTreeSet<String>,
20+
disable_rulesets_repos: BTreeSet<String>,
2121
}
2222

2323
impl Config {
@@ -49,8 +49,8 @@ impl Config {
4949
&self.members_without_zulip_id
5050
}
5151

52-
pub(crate) fn enable_rulesets_repos(&self) -> &BTreeSet<String> {
53-
&self.enable_rulesets_repos
52+
pub(crate) fn disable_rulesets_repos(&self) -> &BTreeSet<String> {
53+
&self.disable_rulesets_repos
5454
}
5555
}
5656

src/sync/github/api/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ where
414414
}
415415

416416
/// An object with a `login` field
417-
#[derive(Deserialize, Debug, Clone, PartialEq, Eq)]
417+
#[derive(Deserialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
418418
pub(crate) struct Login {
419419
pub(crate) login: String,
420420
}
@@ -456,7 +456,7 @@ fn team_node_id(id: u64) -> String {
456456
BASE64_STANDARD.encode(format!("04:Team{id}"))
457457
}
458458

459-
#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize)]
459+
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, serde::Deserialize)]
460460
#[serde(rename_all = "camelCase")]
461461
pub(crate) struct BranchProtection {
462462
pub(crate) pattern: String,
@@ -501,7 +501,7 @@ where
501501
}
502502

503503
/// Entities that can be allowed to push to a branch in a repo
504-
#[derive(Clone, Deserialize, Debug, PartialEq, Eq)]
504+
#[derive(Clone, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord)]
505505
#[serde(untagged)]
506506
pub(crate) enum PushAllowanceActor {
507507
User(UserPushAllowanceActor),
@@ -510,20 +510,20 @@ pub(crate) enum PushAllowanceActor {
510510
}
511511

512512
/// User who can be allowed to push to a branch in a repo
513-
#[derive(Clone, Deserialize, Debug, PartialEq, Eq)]
513+
#[derive(Clone, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord)]
514514
pub(crate) struct UserPushAllowanceActor {
515515
pub(crate) login: String,
516516
}
517517

518518
/// Team that can be allowed to push to a branch in a repo
519-
#[derive(Clone, Deserialize, Debug, PartialEq, Eq)]
519+
#[derive(Clone, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord)]
520520
pub(crate) struct TeamPushAllowanceActor {
521521
pub(crate) organization: Login,
522522
pub(crate) name: String,
523523
}
524524

525525
/// GitHub app that can be allowed to push to a branch in a repo
526-
#[derive(Clone, Deserialize, Debug, PartialEq, Eq)]
526+
#[derive(Clone, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord)]
527527
pub(crate) struct AppPushAllowanceActor {
528528
pub(crate) name: String,
529529
/// Node ID, which can be used as a push actor ID

src/sync/github/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl SyncGitHub {
444444
/// Check if a repository should use rulesets instead of branch protections
445445
fn should_use_rulesets(&self, repo: &rust_team_data::v1::Repo) -> bool {
446446
let repo_full_name = format!("{}/{}", repo.org, repo.name);
447-
self.config.enable_rulesets_repos.contains(&repo_full_name)
447+
!self.config.disable_rulesets_repos.contains(&repo_full_name)
448448
}
449449

450450
async fn diff_repo(
@@ -609,15 +609,15 @@ impl SyncGitHub {
609609
&self,
610610
actual_repo: &api::Repo,
611611
expected_repo: &rust_team_data::v1::Repo,
612-
) -> anyhow::Result<Vec<BranchProtectionDiff>> {
612+
) -> anyhow::Result<BTreeSet<BranchProtectionDiff>> {
613613
// The rust-lang/rust repository uses GitHub apps push allowance actors for its branch
614614
// protections, which cannot be read without a PAT.
615615
// To avoid errors, we simply return an empty diff here.
616616
if !self.github.uses_pat() && actual_repo.org == "rust-lang" && actual_repo.name == "rust" {
617-
return Ok(vec![]);
617+
return Ok(BTreeSet::new());
618618
}
619619

620-
let mut branch_protection_diffs = Vec::new();
620+
let mut branch_protection_diffs = BTreeSet::new();
621621
let mut actual_protections = self
622622
.github
623623
.branch_protections(&actual_repo.org, &actual_repo.name)
@@ -668,10 +668,10 @@ impl SyncGitHub {
668668
Some(_) => continue,
669669
}
670670
};
671-
branch_protection_diffs.push(BranchProtectionDiff {
671+
branch_protection_diffs.insert(BranchProtectionDiff {
672672
pattern: branch_protection.pattern.clone(),
673673
operation,
674-
})
674+
});
675675
}
676676

677677
// `actual_branch_protections` now contains the branch protections that were not expected
@@ -1569,7 +1569,7 @@ struct UpdateRepoDiff {
15691569
// old, new
15701570
settings_diff: (RepoSettings, RepoSettings),
15711571
permission_diffs: Vec<RepoPermissionAssignmentDiff>,
1572-
branch_protection_diffs: Vec<BranchProtectionDiff>,
1572+
branch_protection_diffs: BTreeSet<BranchProtectionDiff>,
15731573
ruleset_diffs: Vec<RulesetDiff>,
15741574
environment_diffs: Vec<EnvironmentDiff>,
15751575
app_installation_diffs: Vec<AppInstallationDiff>,
@@ -1898,7 +1898,7 @@ enum RepoCollaborator {
18981898
User(String),
18991899
}
19001900

1901-
#[derive(Debug)]
1901+
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
19021902
struct BranchProtectionDiff {
19031903
pattern: String,
19041904
operation: BranchProtectionDiffOperation,
@@ -2452,7 +2452,7 @@ fn log_ruleset(
24522452
Ok(())
24532453
}
24542454

2455-
#[derive(Debug)]
2455+
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
24562456
enum BranchProtectionDiffOperation {
24572457
Create(api::BranchProtection),
24582458
Update(String, api::BranchProtection, api::BranchProtection),

0 commit comments

Comments
 (0)