Skip to content
Draft
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
12 changes: 6 additions & 6 deletions docs/toml-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ members = [
# Past members of the team. They will not be considered as part of the team,
# but they will be recognized on the website.
#
# Most teams are required to have this alumni key, even if its value is an empty
# Most teams are required to have this alums key, even if its value is an empty
# array. It is only optional in teams with kind="marker-team", and in teams
# which comprise only members of other teams via include-team-leads or similar.
alumni = [
alums = [
"buildbot",
]
# Optional, name of other teams whose members will be included as members of this team.
Expand All @@ -116,10 +116,10 @@ include-wg-leads = false
# DO NOT USE, this is intended only for the `project-group-leads` team.
# Include "project-group-leads" in `included-teams` instead.
include-project-group-leads = false
# Include all alumni. Optional, defaults to false.
# DO NOT USE, this is intended only for the `alumni` team.
# Include "alumni" in `included-teams` instead.
include-all-alumni = false
# Include all alums. Optional, defaults to false.
# DO NOT USE, this is intended only for the `alums` team.
# Include "alums" in `included-teams` instead.
include-all-alums = false

[permissions]
# Optional, applies to all team members. See the permissions documentation
Expand Down
1 change: 1 addition & 0 deletions rust_team_data/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct Team {
#[serde(skip_serializing_if = "Option::is_none")]
pub top_level: Option<bool>,
pub members: Vec<TeamMember>,
pub alums: Vec<TeamMember>,
pub alumni: Vec<TeamMember>,
pub github: Option<TeamGitHub>,
pub website_data: Option<TeamWebsite>,
Expand Down
4 changes: 2 additions & 2 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ impl Data {
self.people.values()
}

/// Return the usernames of all active members, i.e. all members of non-alumni teams.
/// Return the usernames of all active members, i.e. all members of non-alums teams.
/// It also includes members of teams that don't have a `[[github]]` section.
pub(crate) fn active_members(&self) -> Result<HashSet<&str>, Error> {
let mut active = HashSet::new();
for team in self.teams.values().filter(|team| !team.is_alumni_team()) {
for team in self.teams.values().filter(|team| !team.is_alums_team()) {
active.extend(team.members(self)?)
}
Ok(active)
Expand Down
2 changes: 1 addition & 1 deletion src/find_inactive_members.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async fn find_team_members(
true
}
})
.filter(|team| team.name != "alumni" && team.name != "all" && team.name != "leads")
.filter(|team| team.name != "alums" && team.name != "all" && team.name != "leads")
.collect::<Vec<_>>();

let mut team_members = HashSet::new();
Expand Down
40 changes: 20 additions & 20 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::find_inactive_members::{InactiveTeamFilter, find_inactive_members};
use crate::schema::RepoPermission;
use crate::sync::run_sync_team;
use crate::sync::team_api::TeamApi;
use crate::toml_manipulation::{archive_repo, archive_team, move_person_to_alumni};
use crate::toml_manipulation::{archive_repo, archive_team, move_person_to_alums};
use anyhow::{Context, Error, bail, format_err};
use api::github;
use chrono::Utc;
Expand All @@ -49,10 +49,10 @@ enum DumpIndividualAccessGroupBy {
}

#[derive(clap::ValueEnum, Clone, Debug)]
enum CreateAlumniPr {
/// Create the alumni pull request on your behalf.
enum CreateAlumsPr {
/// Create the alums pull request on your behalf.
Myself,
/// Create the alumni pull request of behalf of someone else, who you are moving to alumni
/// Create the alums pull request of behalf of someone else, who you are moving to alums
/// status.
External,
}
Expand Down Expand Up @@ -135,23 +135,23 @@ enum RootOpts {
#[arg(long, default_value = "30")]
cutoff_days: u64,
},
/// Move a person to alumni status
MoveToAlumni {
/// Move a person to alums
MoveToAlums {
/// GitHub username of the person.
username: String,
/// Subset of teams in which the person should be moved to alumni.
/// If not specified, then the person will be moved to alumni in all their teams.
/// Subset of teams in which the person should be moved to alums.
/// If not specified, then the person will be moved to alums in all their teams.
#[arg(long, value_delimiter = ',')]
teams: Vec<String>,
/// Create a git commit after moving the person to alumni and then
/// Create a git commit after moving the person to alums and then
/// create a pull request using the `gh` CLI tool.
///
/// You will be redirected to the GitHub web interface to confirm the PR.
///
/// Specify either `myself` or `external`, based on whether you are moving yourself to
/// alumni, or if you are moving someone else to alumni.
/// alums, or if you are moving someone else to alums.
#[arg(long)]
create_pr: Option<CreateAlumniPr>,
create_pr: Option<CreateAlumsPr>,
},
/// Encrypt an email address
EncryptEmail,
Expand Down Expand Up @@ -630,13 +630,13 @@ async fn run() -> Result<(), Error> {
)
.await?
}
RootOpts::MoveToAlumni {
RootOpts::MoveToAlums {
username,
teams,
create_pr,
} => {
let specific_teams = !teams.is_empty();
let removed_teams = move_person_to_alumni(&data, &cli.data_dir, &username, teams)?;
let removed_teams = move_person_to_alums(&data, &cli.data_dir, &username, teams)?;
if !removed_teams.is_empty()
&& let Some(create_pr) = create_pr
{
Expand All @@ -651,22 +651,22 @@ async fn run() -> Result<(), Error> {
} else {
String::new()
};
let title = format!("Move `{username}` to alumni{title_suffix}");
let title = format!("Move `{username}` to alums{title_suffix}");

let date = Utc::now() + chrono::Duration::days(10);
let body = match create_pr {
CreateAlumniPr::Myself => {
CreateAlumsPr::Myself => {
format!(
r#"Move myself to alumni{title_suffix}.
r#"Move myself to alums{title_suffix}.

@rustbot label +alumni
@rustbot label +alums
"#
)
}
CreateAlumniPr::External => format!(
CreateAlumsPr::External => format!(
r#"{title}, as they have been inactive on GitHub and Zulip for some time. This is in accordance with https://github.com/rust-lang/leadership-council/blob/main/policies/membership/auto-alumni.md.

`{username}` will be moved to alumni in the following team(s):
`{username}` will be moved to alums in the following team(s):
{}

This pull request should be left open at least for 10 days (until `{}`) to allow the contributor to respond.
Expand All @@ -675,7 +675,7 @@ CC @{username}

If you want to keep being a member of Rust teams, please let us know!

@rustbot label +alumni
@rustbot label +alums
"#,
removed_teams
.iter()
Expand Down
24 changes: 12 additions & 12 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,23 +355,23 @@ impl Team {
for team in data.teams() {
if team.kind != TeamKind::Team
|| team.name == self.name
// This matches the special alumni team.
|| team.is_alumni_team()
// This matches the special alums team.
|| team.is_alums_team()
{
continue;
}
members.extend(team.members(data)?);
}
}
if self.is_alumni_team() {
if self.is_alums_team() {
let active_members = data.active_members()?;
let alumni = data
let alums = data
.teams()
.chain(data.archived_teams())
.flat_map(|t| t.explicit_alumni())
.flat_map(|t| t.explicit_alums())
.map(|a| a.github.as_str())
.filter(|person| !active_members.contains(person));
members.extend(alumni);
members.extend(alums);
}
Ok(members)
}
Expand Down Expand Up @@ -559,17 +559,17 @@ impl Team {
Ok(result)
}

pub(crate) fn is_alumni_team(&self) -> bool {
self.people.include_all_alumni
pub(crate) fn is_alums_team(&self) -> bool {
self.people.include_all_alums
}

// People explicitly set as members
pub(crate) fn explicit_members(&self) -> &[TeamMember] {
&self.people.members
}

pub(crate) fn explicit_alumni(&self) -> &[TeamMember] {
self.people.alumni.as_ref().map_or(&[], Vec::as_slice)
pub(crate) fn explicit_alums(&self) -> &[TeamMember] {
self.people.alums.as_ref().map_or(&[], Vec::as_slice)
}

pub(crate) fn explicit_leads(&self) -> &[String] {
Expand Down Expand Up @@ -606,7 +606,7 @@ impl std::cmp::Ord for GitHubTeam<'_> {
pub(crate) struct TeamPeople {
pub leads: Vec<String>,
pub members: Vec<TeamMember>,
pub alumni: Option<Vec<TeamMember>>,
pub alums: Option<Vec<TeamMember>>,
#[serde(default)]
pub included_teams: Vec<String>,
#[serde(default = "default_false")]
Expand All @@ -618,7 +618,7 @@ pub(crate) struct TeamPeople {
#[serde(default = "default_false")]
pub include_all_team_members: bool,
#[serde(default = "default_false")]
pub include_all_alumni: bool,
pub include_all_alums: bool,
}

#[derive(serde::Deserialize, Clone, Debug)]
Expand Down
13 changes: 7 additions & 6 deletions src/static_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ fn convert_teams<'a>(
for member in team.explicit_members().iter().cloned() {
website_roles.insert(member.github, member.roles);
}
for alum in team.explicit_alumni().iter().cloned() {
for alum in team.explicit_alums().iter().cloned() {
website_roles.insert(alum.github, alum.roles);
}

Expand All @@ -629,10 +629,10 @@ fn convert_teams<'a>(
members.sort_by_key(|member| member.github.to_lowercase());
members.sort_by_key(|member| !member.is_lead);

let mut alumni = Vec::new();
for alum in team.explicit_alumni() {
let mut alums = Vec::new();
for alum in team.explicit_alums() {
if let Some(person) = data.person(&alum.github) {
alumni.push(v1::TeamMember {
alums.push(v1::TeamMember {
name: person.name().into(),
github: alum.github.to_string(),
github_id: person.github_id(),
Expand All @@ -648,7 +648,7 @@ fn convert_teams<'a>(
});
}
}
alumni.sort_by_key(|member| member.github.to_lowercase());
alums.sort_by_key(|member| member.github.to_lowercase());

let mut github_teams = team.github_teams(data)?;
github_teams.sort();
Expand All @@ -664,7 +664,8 @@ fn convert_teams<'a>(
subteam_of: team.subteam_of().map(|st| st.into()),
top_level: team.top_level(),
members,
alumni,
alumni: alums.clone(),
alums,
github: Some(v1::TeamGitHub {
teams: github_teams
.into_iter()
Expand Down
1 change: 1 addition & 0 deletions src/sync/github/tests/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ impl From<TeamData> for v1::Team {
subteam_of: None,
top_level: None,
members: vec![],
alums: vec![],
alumni: vec![],
github: (!gh_teams.is_empty()).then_some(TeamGitHub { teams: gh_teams }),
website_data: None,
Expand Down
1 change: 1 addition & 0 deletions src/sync/gws/tests/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub fn normal_team(name: &str, members: Vec<TeamMember>) -> Team {
website_data: None,
subteam_of: None,
top_level: Some(true),
alums: vec![],
alumni: vec![],
roles: vec![],
google_workspace_saml_group: None,
Expand Down
30 changes: 15 additions & 15 deletions src/toml_manipulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn archive_repo(data_dir: &Path, name: &str) -> anyhow::Result<()> {
})
}

/// Gather every username from a team's `leads`, `members`, and `alumni`
/// Gather every username from a team's `leads`, `members`, and `alums`
/// arrays into a single deduplicated, order-preserving set.
///
/// Handles both bare strings (`"alice"`) and inline tables (`{ github = "alice" }`),
Expand All @@ -77,7 +77,7 @@ pub fn archive_repo(data_dir: &Path, name: &str) -> anyhow::Result<()> {
fn collect_all_team_members(people_table: &toml_edit::Table) -> Vec<toml_edit::Value> {
let mut all = IndexSet::new();
let mut values = Vec::new();
for key in ["leads", "members", "alumni"] {
for key in ["leads", "members", "alums"] {
let Some(arr) = people_table.get(key).and_then(|v| v.as_array()) else {
continue;
};
Expand All @@ -102,7 +102,7 @@ fn collect_all_team_members(people_table: &toml_edit::Table) -> Vec<toml_edit::V

/// Build a TOML array of usernames laid out one per line with ` ` indentation
/// and a trailing comma — matching the style used elsewhere in the team repo.
fn build_alumni_array(values: &[toml_edit::Value]) -> toml_edit::Array {
fn build_alums_array(values: &[toml_edit::Value]) -> toml_edit::Array {
let mut arr = toml_edit::Array::new();
for value in values {
let mut value = value.clone();
Expand All @@ -115,32 +115,32 @@ fn build_alumni_array(values: &[toml_edit::Value]) -> toml_edit::Array {
arr
}

/// Move everyone listed in a team's `leads`, `members`, and existing `alumni`
/// into a single `alumni` array, leaving `leads` and `members` empty.
/// Move everyone listed in a team's `leads`, `members`, and existing `alums`
/// into a single `alums` array, leaving `leads` and `members` empty.
///
/// No-op if the document has no `[people]` table.
fn move_team_members_to_alumni(doc: &mut toml_edit::DocumentMut) {
fn move_team_members_to_alums(doc: &mut toml_edit::DocumentMut) {
let Some(people_table) = doc.get_mut("people").and_then(|v| v.as_table_mut()) else {
return;
};

let all_alumni = collect_all_team_members(people_table);
let all_alums = collect_all_team_members(people_table);

people_table.insert("leads", toml_edit::Array::new().into());
people_table.insert("members", toml_edit::Array::new().into());
people_table.insert("alumni", build_alumni_array(&all_alumni).into());
people_table.insert("alums", build_alums_array(&all_alums).into());
}

/// Archive a team by moving its TOML file to `teams/archive/`, collapsing
/// every `leads`/`members`/`alumni` entry into a single `alumni` array,
/// every `leads`/`members`/`alums` entry into a single `alums` array,
/// and removing the team from every repo's `[access.teams]` table.
pub fn archive_team(data_dir: &Path, name: &str) -> anyhow::Result<()> {
let teams_dir = data_dir.join("teams");
let src = teams_dir.join(format!("{name}.toml"));
let dest_dir = teams_dir.join("archive");
let dest = dest_dir.join(format!("{name}.toml"));

archive_toml_file(&src, &dest_dir, &dest, "team", move_team_members_to_alumni)?;
archive_toml_file(&src, &dest_dir, &dest, "team", move_team_members_to_alums)?;
remove_team_from_repos(data_dir, name)?;
Ok(())
}
Expand Down Expand Up @@ -198,7 +198,7 @@ fn remove_team_from_repository(team_name: &str, repo_path: &Path) -> anyhow::Res
Ok(())
}

pub fn move_person_to_alumni<'a>(
pub fn move_person_to_alums<'a>(
data: &'a Data,
data_dir: &Path,
username: &str,
Expand Down Expand Up @@ -277,13 +277,13 @@ pub fn move_person_to_alumni<'a>(
};
let entry = members.remove(index);

let alumni = people
.entry("alumni")
let alums = people
.entry("alums")
.or_insert(Item::Value(Value::Array(Array::new())))
.as_array_mut()
.unwrap();
alumni.push_formatted(entry);
*alumni = build_alumni_array(&alumni.iter().cloned().collect::<Vec<_>>());
alums.push_formatted(entry);
*alums = build_alums_array(&alums.iter().cloned().collect::<Vec<_>>());

std::fs::write(path, document.to_string())?;
}
Expand Down
Loading