Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Even more libs contributors #881

Merged
merged 7 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from 6 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
4 changes: 4 additions & 0 deletions people/Darksonn.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name = 'Alice Ryhl'
github = 'Darksonn'
github-id = 928074
email = '[email protected]'
4 changes: 4 additions & 0 deletions people/Thomasdezeeuw.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name = 'Thomas de Zeeuw'
github = 'Thomasdezeeuw'
github-id = 3159064
email = '[email protected]'
4 changes: 4 additions & 0 deletions people/carllerche.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name = 'Carl Lerche'
github = 'carllerche'
github-id = 6180
email = '[email protected]'
4 changes: 4 additions & 0 deletions people/chansuke.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name = 'chansuke'
github = 'chansuke'
github-id = 501052
email = '[email protected]'
13 changes: 13 additions & 0 deletions repos/rust-lang/backtrace-rs.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
org = 'rust-lang'
name = 'backtrace-rs'
description = 'Backtraces in Rust'
bots = []

[access.teams]
libs-contributors = 'maintain'

[access.individuals]
alexcrichton = 'write'

[[branch]]
name = 'master'
14 changes: 14 additions & 0 deletions repos/rust-lang/flate2-rs.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
org = 'rust-lang'
name = 'flate2-rs'
description = 'DEFLATE, gzip, and zlib bindings for Rust'
bots = []

[access.teams]
libs-contributors = 'maintain'
rylev marked this conversation as resolved.
Show resolved Hide resolved

[access.individuals]
alexcrichton = 'maintain'
brson = 'write'

[[branch]]
name = 'main'
7 changes: 7 additions & 0 deletions repos/rust-lang/getopts.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
org = 'rust-lang'
name = 'getopts'
description = 'The getopts repo maintained by the rust-lang project'
bots = []

[access.teams]
libs-contributors = 'maintain'
25 changes: 25 additions & 0 deletions repos/rust-lang/socket2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
org = 'rust-lang'
name = 'socket2'
description = 'Advanced configuration options for sockets.'
bots = []

[access.teams]
libs-contributors = '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)',
]
49 changes: 48 additions & 1 deletion src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,22 @@ impl GitHubApi {
Ok(resp.error_for_status()?.json()?)
}

pub(crate) fn repo_collaborators(
&self,
org: &str,
repo: &str,
) -> Result<Vec<RepoCollaborator>, 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<Vec<Branch>, Error> {
let resp = self
.prepare(
Expand Down Expand Up @@ -258,7 +274,7 @@ pub(crate) struct GitHubMember {

#[derive(serde::Deserialize, Debug)]
pub(crate) struct Repo {
pub(crate) description: String,
pub(crate) description: Option<String>,
}

#[derive(serde::Deserialize, Debug)]
Expand Down Expand Up @@ -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"
}
}
}
15 changes: 13 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String>,
#[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
individuals: HashMap<String, String>,
}
#[derive(serde::Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
Expand Down Expand Up @@ -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)?;
Expand All @@ -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");
Expand Down