Skip to content

Commit

Permalink
Merge pull request #1716 from apiraino/autoadd-team-label-on-assignment
Browse files Browse the repository at this point in the history
Autoadd team label on issue/pr assignment
  • Loading branch information
Mark-Simulacrum authored Sep 23, 2023
2 parents dbfa735 + 4f53243 commit 2ab128e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/handlers/assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 2ab128e

Please sign in to comment.