Skip to content

Commit 2ab128e

Browse files
Merge pull request #1716 from apiraino/autoadd-team-label-on-assignment
Autoadd team label on issue/pr assignment
2 parents dbfa735 + 4f53243 commit 2ab128e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/handlers/assign.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,22 @@ pub(super) async fn handle_command(
487487
name.to_string()
488488
} else {
489489
let teams = crate::team_data::teams(&ctx.github).await?;
490+
// Determine if assignee is a team. If yes, add the corresponding label
491+
// team name here is without prefix 't-' (e.g. 'compiler', 'libs', etc.)
492+
if let Some(team) = teams.teams.get(&name) {
493+
let t_label = format!("t-{}", &team.name);
494+
if let Err(err) = issue
495+
.add_labels(&ctx.github, vec![github::Label { name: t_label }])
496+
.await
497+
{
498+
if let Some(github::UnknownLabels { .. }) = err.downcast_ref() {
499+
log::warn!("Error assigning label: {}", err);
500+
} else {
501+
return Err(err);
502+
}
503+
}
504+
}
505+
490506
match find_reviewer_from_names(&teams, config, issue, &[name]) {
491507
Ok(assignee) => assignee,
492508
Err(e) => {

0 commit comments

Comments
 (0)