From 4f53243193b77c5a2ee794f7c952b0abf6479a2b Mon Sep 17 00:00:00 2001 From: apiraino Date: Wed, 6 Sep 2023 17:29:53 +0200 Subject: [PATCH] autoadd team label on issue assignment --- src/handlers/assign.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/handlers/assign.rs b/src/handlers/assign.rs index 4a7d7f1d..86ee477d 100644 --- a/src/handlers/assign.rs +++ b/src/handlers/assign.rs @@ -487,6 +487,22 @@ pub(super) async fn handle_command( name.to_string() } else { let teams = crate::team_data::teams(&ctx.github).await?; + // Determine if assignee is a team. If yes, add the corresponding label + // team name here is without prefix 't-' (e.g. 'compiler', 'libs', etc.) + if let Some(team) = teams.teams.get(&name) { + let t_label = format!("t-{}", &team.name); + if let Err(err) = issue + .add_labels(&ctx.github, vec![github::Label { name: t_label }]) + .await + { + if let Some(github::UnknownLabels { .. }) = err.downcast_ref() { + log::warn!("Error assigning label: {}", err); + } else { + return Err(err); + } + } + } + match find_reviewer_from_names(&teams, config, issue, &[name]) { Ok(assignee) => assignee, Err(e) => {