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
87 changes: 2 additions & 85 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,89 +83,6 @@ members-without-zulip-id = [
"rust-timer",
]

enable-rulesets-repos = [
"rust-analyzer/expect-test",
"rust-lang-nursery/rust-toolstate",
"rust-lang/annotate-snippets-rs",
"rust-lang/arewewebyet",
"rust-lang/async-fundamentals-initiative",
"rust-lang/backtrace-rs",
"rust-lang/beyond-refs",
"rust-lang/blog.rust-lang.org",
"rust-lang/book",
"rust-lang/bors",
"rust-lang/calendar-generation",
"rust-lang/calendar",
"rust-lang/cargo-bisect-rustc",
"rust-lang/cargo",
"rust-lang/cc-rs",
"rust-lang/ci-mirrors",
"rust-lang/cmake-rs",
"rust-lang/compiler-builtins",
"rust-lang/compiler-team",
"rust-lang/crater",
"rust-lang/crates_io_og_image",
"rust-lang/crates-build-env",
"rust-lang/crates-io-auth-action",
"rust-lang/crates.io",
"rust-lang/crates.io-index-archive",
"rust-lang/crates.io-index",
"rust-lang/docs.rs",
"rust-lang/edition-guide",
"rust-lang/ena",
"rust-lang/enzyme",
"rust-lang/flate2-rs",
"rust-lang/fls",
"rust-lang/futures-rs",
"rust-lang/gha-self-hosted",
"rust-lang/git2-rs",
"rust-lang/gll",
"rust-lang/glob",
"rust-lang/hashbrown",
"rust-lang/impl-trait-utils",
"rust-lang/infra-smoke-tests",
"rust-lang/josh-sync",
"rust-lang/leadership-council",
"rust-lang/libc",
"rust-lang/llvm-project",
"rust-lang/mdBook",
"rust-lang/measureme",
"rust-lang/miri",
"rust-lang/miri-test-libstd",
"rust-lang/nomicon",
"rust-lang/odht",
"rust-lang/portable-simd",
"rust-lang/project-stable-mir",
"rust-lang/project-exploit-mitigations",
"rust-lang/promote-release",
"rust-lang/reference",
"rust-lang/relnotes",
"rust-lang/rfcs",
"rust-lang/rust-analyzer",
"rust-lang/rust-bindgen",
"rust-lang/rust-clippy",
"rust-lang/rust-forge",
"rust-lang/rust-log-analyzer",
"rust-lang/rust-playground",
"rust-lang/rustc_codegen_c",
"rust-lang/rustc_codegen_gcc",
"rust-lang/rustc-demangle",
"rust-lang/rustc-dev-guide",
"rust-lang/rustc-hash",
"rust-lang/rustc-perf",
"rust-lang/rustc-stable-hash",
"rust-lang/rustfmt",
"rust-lang/rustup",
"rust-lang/simpleinfra",
"rust-lang/socket2",
"rust-lang/staging.crates.io-index",
"rust-lang/std-dev-guide",
"rust-lang/stdarch",
"rust-lang/team",
"rust-lang/this-week-in-rust",
"rust-lang/thorin",
"rust-lang/triagebot",
"rust-lang/wg-async",
"rust-lang/wg-macros",
"rust-lang/www.rust-lang.org",
disable-rulesets-repos = [
"rust-lang/rust",
]
2 changes: 1 addition & 1 deletion src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl Data {
Ok(sync::Config {
special_org_members,
independent_github_orgs: self.config.independent_github_orgs().clone(),
enable_rulesets_repos: self.config.enable_rulesets_repos().clone(),
disable_rulesets_repos: self.config.disable_rulesets_repos().clone(),
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(crate) struct Config {
special_org_members: BTreeSet<String>,
members_without_zulip_id: BTreeSet<String>,
#[serde(default)]
enable_rulesets_repos: BTreeSet<String>,
disable_rulesets_repos: BTreeSet<String>,
}

impl Config {
Expand Down Expand Up @@ -49,8 +49,8 @@ impl Config {
&self.members_without_zulip_id
}

pub(crate) fn enable_rulesets_repos(&self) -> &BTreeSet<String> {
&self.enable_rulesets_repos
pub(crate) fn disable_rulesets_repos(&self) -> &BTreeSet<String> {
&self.disable_rulesets_repos
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/sync/github/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ where
}

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

#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct BranchProtection {
pub(crate) pattern: String,
Expand Down Expand Up @@ -501,7 +501,7 @@ where
}

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

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

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

/// GitHub app that can be allowed to push to a branch in a repo
#[derive(Clone, Deserialize, Debug, PartialEq, Eq)]
#[derive(Clone, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub(crate) struct AppPushAllowanceActor {
pub(crate) name: String,
/// Node ID, which can be used as a push actor ID
Expand Down
8 changes: 4 additions & 4 deletions src/sync/github/api/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use anyhow::Context as _;
use async_trait::async_trait;
use reqwest::{Method, StatusCode};
use rust_team_data::v1::Environment;
use std::collections::{HashMap, HashSet};
use std::collections::{BTreeMap, HashMap, HashSet};

#[async_trait]
pub(crate) trait GithubRead {
Expand Down Expand Up @@ -74,7 +74,7 @@ pub(crate) trait GithubRead {
&self,
org: &str,
repo: &str,
) -> anyhow::Result<HashMap<String, (String, BranchProtection)>>;
) -> anyhow::Result<BTreeMap<String, (String, BranchProtection)>>;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

changed this so that we order the branch protections when we read them from GitHub


/// Get environments for a repository
/// Returns a map of environment names to their Environment data
Expand Down Expand Up @@ -512,7 +512,7 @@ impl GithubRead for GitHubApiRead {
&self,
org: &str,
repo: &str,
) -> anyhow::Result<HashMap<String, (String, BranchProtection)>> {
) -> anyhow::Result<BTreeMap<String, (String, BranchProtection)>> {
#[derive(serde::Serialize)]
struct Params<'a> {
org: &'a str,
Expand Down Expand Up @@ -576,7 +576,7 @@ impl GithubRead for GitHubApiRead {
protection: BranchProtection,
}

let mut result = HashMap::new();
let mut result = BTreeMap::new();
let res: Wrapper = self
.client
.graphql(QUERY, Params { org, repo }, org)
Expand Down
4 changes: 2 additions & 2 deletions src/sync/github/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ impl SyncGitHub {
/// Check if a repository should use rulesets instead of branch protections
fn should_use_rulesets(&self, repo: &rust_team_data::v1::Repo) -> bool {
let repo_full_name = format!("{}/{}", repo.org, repo.name);
self.config.enable_rulesets_repos.contains(&repo_full_name)
!self.config.disable_rulesets_repos.contains(&repo_full_name)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

here is where the logic changes

}

async fn diff_repo(
Expand Down Expand Up @@ -671,7 +671,7 @@ impl SyncGitHub {
branch_protection_diffs.push(BranchProtectionDiff {
pattern: branch_protection.pattern.clone(),
operation,
})
});
}

// `actual_branch_protections` now contains the branch protections that were not expected
Expand Down
Loading