Skip to content

Commit 3d23df5

Browse files
authored
Merge pull request #2397 from rust-lang/use-rulesets-by-default
use rulesets by default
2 parents d12b9d8 + 4913044 commit 3d23df5

File tree

9 files changed

+268
-208
lines changed

9 files changed

+268
-208
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/api/read.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use anyhow::Context as _;
1111
use async_trait::async_trait;
1212
use reqwest::{Method, StatusCode};
1313
use rust_team_data::v1::Environment;
14-
use std::collections::{HashMap, HashSet};
14+
use std::collections::{BTreeMap, HashMap, HashSet};
1515

1616
#[async_trait]
1717
pub(crate) trait GithubRead {
@@ -74,7 +74,7 @@ pub(crate) trait GithubRead {
7474
&self,
7575
org: &str,
7676
repo: &str,
77-
) -> anyhow::Result<HashMap<String, (String, BranchProtection)>>;
77+
) -> anyhow::Result<BTreeMap<String, (String, BranchProtection)>>;
7878

7979
/// Get environments for a repository
8080
/// Returns a map of environment names to their Environment data
@@ -512,7 +512,7 @@ impl GithubRead for GitHubApiRead {
512512
&self,
513513
org: &str,
514514
repo: &str,
515-
) -> anyhow::Result<HashMap<String, (String, BranchProtection)>> {
515+
) -> anyhow::Result<BTreeMap<String, (String, BranchProtection)>> {
516516
#[derive(serde::Serialize)]
517517
struct Params<'a> {
518518
org: &'a str,
@@ -576,7 +576,7 @@ impl GithubRead for GitHubApiRead {
576576
protection: BranchProtection,
577577
}
578578

579-
let mut result = HashMap::new();
579+
let mut result = BTreeMap::new();
580580
let res: Wrapper = self
581581
.client
582582
.graphql(QUERY, Params { org, repo }, org)

src/sync/github/mod.rs

Lines changed: 2 additions & 2 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(
@@ -671,7 +671,7 @@ impl SyncGitHub {
671671
branch_protection_diffs.push(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

0 commit comments

Comments
 (0)