Browse Source

Merge pull request #1645 from aDotInTheVoid/fix-empty-cc

mentions: Correctly handle empty CC list
Mark Rousskov 2 years ago
parent
commit
1a9b8b860b
1 changed files with 8 additions and 6 deletions
  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
             .paths
             .iter()
-            // Only mention matching paths.
-            // Don't mention if only the author is in the list.
             .filter(|(path, MentionsPathConfig { cc, .. })| {
                 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())
             .collect();