Skip to content

Commit c84ab75

Browse files
authored
Merge pull request #2021 from ehuss/github-team-name
Fix errors due to github team name mismatch
2 parents b2e582b + 439b74c commit c84ab75

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/github.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,25 @@ pub async fn get_team(
290290
Ok(map.swap_remove(team))
291291
}
292292

293+
/// Fetches a Rust team via its GitHub team name.
294+
pub async fn get_team_by_github_name(
295+
client: &GithubClient,
296+
org: &str,
297+
team: &str,
298+
) -> anyhow::Result<Option<rust_team_data::v1::Team>> {
299+
let teams = crate::team_data::teams(client).await?;
300+
for rust_team in teams.teams.into_values() {
301+
if let Some(github) = &rust_team.github {
302+
for gh_team in &github.teams {
303+
if gh_team.org == org && gh_team.name == team {
304+
return Ok(Some(rust_team));
305+
}
306+
}
307+
}
308+
}
309+
Ok(None)
310+
}
311+
293312
#[derive(PartialEq, Eq, Debug, Clone, serde::Deserialize)]
294313
pub struct Label {
295314
pub name: String,

src/handlers/notification.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ async fn id_from_user(
125125
ctx: &Context,
126126
login: &str,
127127
) -> anyhow::Result<Option<(Vec<github::User>, Option<String>)>> {
128-
if login.contains('/') {
128+
if let Some((org, team)) = login.split_once('/') {
129129
// This is a team ping. For now, just add it to everyone's agenda on
130130
// that team, but also mark it as such (i.e., a team ping) for
131131
// potentially different prioritization and so forth.
@@ -136,11 +136,7 @@ async fn id_from_user(
136136
//
137137
// We may also want to be able to categorize into these buckets
138138
// *after* the ping occurs and is initially processed.
139-
140-
let mut iter = login.split('/');
141-
let _rust_lang = iter.next().unwrap();
142-
let team = iter.next().unwrap();
143-
let team = match github::get_team(&ctx.github, team).await {
139+
let team = match github::get_team_by_github_name(&ctx.github, org, team).await {
144140
Ok(Some(team)) => team,
145141
Ok(None) => {
146142
// If the team is in rust-lang*, then this is probably an error (potentially user

0 commit comments

Comments
 (0)