浏览代码

mentions: Correctly handle empty CC list

Closes #1644
Nixon Enraght-Moony 2 年之前
父节点
当前提交
6ee0af8b18
共有 1 个文件被更改,包括 8 次插入6 次删除
  1. 8 6
      src/handlers/mentions.rs

+ 8 - 6
src/handlers/mentions.rs

@@ -61,14 +61,16 @@ pub(super) async fn parse_input(
         let to_mention: Vec<_> = config
         let to_mention: Vec<_> = config
             .paths
             .paths
             .iter()
             .iter()
-            // Only mention matching paths.
-            // Don't mention if only the author is in the list.
             .filter(|(path, MentionsPathConfig { cc, .. })| {
             .filter(|(path, MentionsPathConfig { cc, .. })| {
                 let path = Path::new(path);
                 let path = Path::new(path);
-                file_paths.iter().any(|p| p.starts_with(path))
-                    && !cc
-                        .iter()
-                        .all(|r| r.trim_start_matches('@') == &event.issue.user.login)
+                // Only mention matching paths.
+                let touches_relevant_files = file_paths.iter().any(|p| p.starts_with(path));
+                // Don't mention if only the author is in the list.
+                let pings_non_author = match &cc[..] {
+                    [only_cc] => only_cc.trim_start_matches('@') != &event.issue.user.login,
+                    _ => true,
+                };
+                touches_relevant_files && pings_non_author
             })
             })
             .map(|(key, _mention)| key.to_string())
             .map(|(key, _mention)| key.to_string())
             .collect();
             .collect();