Skip to content

Commit f7a3336

Browse files
authored
Merge pull request #1727 from apiraino/improve_team_labels_parsing
Learn to parse (and clean) team labels with a "t-" prefix
2 parents b53466e + 6e95101 commit f7a3336

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/handlers/assign.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,11 @@ 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);
490+
// remove "t-" or "T-" prefixes before checking if it's a team name
491+
let team_name = name.trim_start_matches("t-").trim_start_matches("T-");
492+
// Determine if assignee is a team. If yes, add the corresponding GH label.
493+
if teams.teams.get(team_name).is_some() {
494+
let t_label = format!("T-{}", &team_name);
494495
if let Err(err) = issue
495496
.add_labels(&ctx.github, vec![github::Label { name: t_label }])
496497
.await
@@ -503,7 +504,8 @@ pub(super) async fn handle_command(
503504
}
504505
}
505506

506-
match find_reviewer_from_names(&teams, config, issue, &[name]) {
507+
match find_reviewer_from_names(&teams, config, issue, &[team_name.to_string()])
508+
{
507509
Ok(assignee) => assignee,
508510
Err(e) => {
509511
issue.post_comment(&ctx.github, &e.to_string()).await?;

0 commit comments

Comments
 (0)