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
4 changes: 4 additions & 0 deletions people/sdroege.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name = "Sebastian Dröge"
github = "sdroege"
github-id = 301846
email = "[email protected]"
10 changes: 10 additions & 0 deletions repos/rust-lang/pkg-config-rs.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
org = "rust-lang"
name = "pkg-config-rs"
description = "Build library for invoking pkg-config for Rust"
bots = []

[access.teams]
crate-maintainers = "maintain"

[access.individuals]
sdroege = "write"
7 changes: 7 additions & 0 deletions rust_team_data/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ pub struct Repo {
pub description: String,
pub bots: Vec<Bot>,
pub teams: Vec<RepoTeam>,
pub members: Vec<RepoMember>,
pub branches: Vec<Branch>,
}

Expand All @@ -162,6 +163,12 @@ pub struct RepoTeam {
pub permission: RepoPermission,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepoMember {
pub name: String,
pub permission: RepoPermission,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum RepoPermission {
Expand Down
2 changes: 2 additions & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,8 @@ pub(crate) enum Bot {
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
pub(crate) struct RepoAccess {
pub teams: HashMap<String, RepoPermission>,
#[serde(default)]
pub individuals: HashMap<String, RepoPermission>,
}

#[derive(serde_derive::Deserialize, Debug)]
Expand Down
17 changes: 17 additions & 0 deletions src/static_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ impl<'a> Generator<'a> {
}
})
.collect(),
members: r
.access
.individuals
.iter()
.map(|(name, permission)| {
let permission = match permission {
RepoPermission::Admin => v1::RepoPermission::Admin,
RepoPermission::Write => v1::RepoPermission::Write,
RepoPermission::Maintain => v1::RepoPermission::Maintain,
RepoPermission::Triage => v1::RepoPermission::Triage,
};
v1::RepoMember {
name: name.clone(),
permission,
}
})
.collect(),
branches: r
.branches
.iter()
Expand Down
21 changes: 19 additions & 2 deletions src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,19 @@ fn validate_inactive_members(data: &Data, errors: &mut Vec<String>) {
);

let all_members = data.people().map(|p| p.github()).collect::<HashSet<_>>();
// All the individual contributors to any Rust controlled repos
let all_ics = data
.repos()
.flat_map(|r| r.access.individuals.keys())
.map(|n| n.as_str())
.collect::<HashSet<_>>();
wrapper(
all_members.difference(&referenced_members),
errors,
|person, _| {
if !data.person(person).unwrap().permissions().has_any() {
if !data.person(person).unwrap().permissions().has_any() && !all_ics.contains(person) {
bail!(
"person `{}` is not a member of any team (active or archived) and has no permissions",
"person `{}` is not a member of any team (active or archived), has no permissions, and is not an individual contributor to any repo",
person
);
}
Expand Down Expand Up @@ -671,6 +677,17 @@ fn validate_repos(data: &Data, errors: &mut Vec<String>) {
);
}
}

for (name, _) in &repo.access.individuals {
if data.person(name).is_none() {
bail!(
"access for {}/{} is invalid: '{}' is not the name of a person in the team repo",
repo.org,
repo.name,
name
);
}
}
Ok(())
});
}
Expand Down
1 change: 1 addition & 0 deletions tests/static-api/_expected/v1/repos.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"permission": "admin"
}
],
"members": [],
"branches": [
{
"name": "master",
Expand Down
1 change: 1 addition & 0 deletions tests/static-api/_expected/v1/repos/some_repo.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"permission": "admin"
}
],
"members": [],
"branches": [
{
"name": "master",
Expand Down