diff --git a/people/Darksonn.toml b/people/Darksonn.toml new file mode 100644 index 000000000..82ff0d972 --- /dev/null +++ b/people/Darksonn.toml @@ -0,0 +1,4 @@ +name = 'Alice Ryhl' +github = 'Darksonn' +github-id = 928074 +email = 'alice@ryhl.io' diff --git a/people/Thomasdezeeuw.toml b/people/Thomasdezeeuw.toml new file mode 100644 index 000000000..709ff2829 --- /dev/null +++ b/people/Thomasdezeeuw.toml @@ -0,0 +1,4 @@ +name = 'Thomas de Zeeuw' +github = 'Thomasdezeeuw' +github-id = 3159064 +email = 'thomasdezeeuw@gmail.com' diff --git a/people/carllerche.toml b/people/carllerche.toml new file mode 100644 index 000000000..767cbc0c9 --- /dev/null +++ b/people/carllerche.toml @@ -0,0 +1,4 @@ +name = 'Carl Lerche' +github = 'carllerche' +github-id = 6180 +email = 'me@carllerche.com' diff --git a/people/chansuke.toml b/people/chansuke.toml new file mode 100644 index 000000000..88f693850 --- /dev/null +++ b/people/chansuke.toml @@ -0,0 +1,4 @@ +name = 'chansuke' +github = 'chansuke' +github-id = 501052 +email = 'moonset20@gmail.com' diff --git a/repos/rust-lang/backtrace-rs.toml b/repos/rust-lang/backtrace-rs.toml new file mode 100644 index 000000000..230809f11 --- /dev/null +++ b/repos/rust-lang/backtrace-rs.toml @@ -0,0 +1,13 @@ +org = 'rust-lang' +name = 'backtrace-rs' +description = 'Backtraces in Rust' +bots = [] + +[access.teams] +crate-maintainers = 'maintain' + +[access.individuals] +alexcrichton = 'write' + +[[branch]] +name = 'master' diff --git a/repos/rust-lang/flate2-rs.toml b/repos/rust-lang/flate2-rs.toml new file mode 100644 index 000000000..8d65f0ea7 --- /dev/null +++ b/repos/rust-lang/flate2-rs.toml @@ -0,0 +1,14 @@ +org = 'rust-lang' +name = 'flate2-rs' +description = 'DEFLATE, gzip, and zlib bindings for Rust' +bots = [] + +[access.teams] +crate-maintainers = 'maintain' + +[access.individuals] +alexcrichton = 'maintain' +brson = 'write' + +[[branch]] +name = 'main' diff --git a/repos/rust-lang/getopts.toml b/repos/rust-lang/getopts.toml new file mode 100644 index 000000000..d266c2a2c --- /dev/null +++ b/repos/rust-lang/getopts.toml @@ -0,0 +1,7 @@ +org = 'rust-lang' +name = 'getopts' +description = 'The getopts repo maintained by the rust-lang project' +bots = [] + +[access.teams] +crate-maintainers = 'maintain' diff --git a/repos/rust-lang/socket2.toml b/repos/rust-lang/socket2.toml new file mode 100644 index 000000000..ee8c1d174 --- /dev/null +++ b/repos/rust-lang/socket2.toml @@ -0,0 +1,25 @@ +org = 'rust-lang' +name = 'socket2' +description = 'Advanced configuration options for sockets.' +bots = [] + +[access.teams] +crate-maintainers = 'maintain' + +[access.individuals] +chansuke = 'triage' +sfackler = 'maintain' +Thomasdezeeuw = 'maintain' +carllerche = 'maintain' +Darksonn = 'maintain' + +[[branch]] +name = 'master' +ci-checks = [ + 'Rustfmt', + 'Test (beta)', + 'Test (macos)', + 'Test (nightly)', + 'Test (stable)', + 'Test (windows)', +] diff --git a/src/github.rs b/src/github.rs index 5525458e7..7003433d3 100644 --- a/src/github.rs +++ b/src/github.rs @@ -211,6 +211,22 @@ impl GitHubApi { Ok(resp.error_for_status()?.json()?) } + pub(crate) fn repo_collaborators( + &self, + org: &str, + repo: &str, + ) -> Result, Error> { + let resp = self + .prepare( + true, + Method::GET, + &format!("repos/{org}/{repo}/collaborators?affiliation=direct"), + )? + .send()?; + + Ok(resp.error_for_status()?.json()?) + } + pub(crate) fn protected_branches(&self, org: &str, repo: &str) -> Result, Error> { let resp = self .prepare( @@ -258,7 +274,7 @@ pub(crate) struct GitHubMember { #[derive(serde::Deserialize, Debug)] pub(crate) struct Repo { - pub(crate) description: String, + pub(crate) description: Option, } #[derive(serde::Deserialize, Debug)] @@ -306,3 +322,34 @@ pub(crate) struct StatusChecks { pub(crate) struct RequiredReviews { pub(crate) dismiss_stale_reviews: bool, } + +#[derive(serde::Deserialize, Debug)] +pub(crate) struct RepoCollaborator { + #[serde(alias = "login")] + pub(crate) name: String, + pub(crate) permissions: Permissions, +} + +#[derive(serde::Deserialize, Debug)] +pub(crate) struct Permissions { + triage: bool, + push: bool, + maintain: bool, + admin: bool, +} + +impl Permissions { + pub(crate) fn highest(&self) -> &str { + if self.admin { + "admin" + } else if self.maintain { + "maintain" + } else if self.push { + "write" + } else if self.triage { + "triage" + } else { + "read" + } + } +} diff --git a/src/main.rs b/src/main.rs index 7b69e587d..c47cb1350 100644 --- a/src/main.rs +++ b/src/main.rs @@ -170,7 +170,10 @@ fn run() -> Result<(), Error> { #[derive(serde::Serialize, Debug)] #[serde(rename_all = "kebab-case")] struct AccessToAdd { + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] teams: HashMap, + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + individuals: HashMap, } #[derive(serde::Serialize, Debug)] #[serde(rename_all = "kebab-case")] @@ -219,6 +222,12 @@ fn run() -> Result<(), Error> { } } + let individuals = github + .repo_collaborators(&org, &name)? + .into_iter() + .map(|c| (c.name, c.permissions.highest().to_owned())) + .collect(); + let mut branches = Vec::new(); for branch in github.protected_branches(&org, &name)? { let protection = github.branch_protection(&org, &name, &branch.name)?; @@ -234,9 +243,11 @@ fn run() -> Result<(), Error> { let repo = RepoToAdd { org: &org, name: &name, - description: &repo.description, + description: &repo.description.unwrap_or_else(|| { + format!("The {name} repo maintained by the rust-lang project") + }), bots, - access: AccessToAdd { teams }, + access: AccessToAdd { teams, individuals }, branch: branches, }; let file = format!("repos/{org}/{name}.toml");