浏览代码

Merge pull request #1727 from apiraino/improve_team_labels_parsing

Learn to parse (and clean) team labels with a "t-" prefix
Eric Huss 1 年之前
父节点
当前提交
f7a3336832
共有 1 个文件被更改,包括 7 次插入5 次删除
  1. 7 5
      src/handlers/assign.rs

+ 7 - 5
src/handlers/assign.rs

@@ -487,10 +487,11 @@ pub(super) async fn handle_command(
                     name.to_string()
                     name.to_string()
                 } else {
                 } else {
                     let teams = crate::team_data::teams(&ctx.github).await?;
                     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);
+                    // remove "t-" or "T-" prefixes before checking if it's a team name
+                    let team_name = name.trim_start_matches("t-").trim_start_matches("T-");
+                    // Determine if assignee is a team. If yes, add the corresponding GH label.
+                    if teams.teams.get(team_name).is_some() {
+                        let t_label = format!("T-{}", &team_name);
                         if let Err(err) = issue
                         if let Err(err) = issue
                             .add_labels(&ctx.github, vec![github::Label { name: t_label }])
                             .add_labels(&ctx.github, vec![github::Label { name: t_label }])
                             .await
                             .await
@@ -503,7 +504,8 @@ pub(super) async fn handle_command(
                         }
                         }
                     }
                     }
 
 
-                    match find_reviewer_from_names(&teams, config, issue, &[name]) {
+                    match find_reviewer_from_names(&teams, config, issue, &[team_name.to_string()])
+                    {
                         Ok(assignee) => assignee,
                         Ok(assignee) => assignee,
                         Err(e) => {
                         Err(e) => {
                             issue.post_comment(&ctx.github, &e.to_string()).await?;
                             issue.post_comment(&ctx.github, &e.to_string()).await?;