@@ -16,8 +16,9 @@ use tracing as log;
1616
1717const MENTIONS_KEY : & str = "mentions" ;
1818
19- pub ( super ) struct MentionsInput {
20- paths : Vec < String > ,
19+ pub ( super ) enum MentionsInput {
20+ HasBorsCommit ,
21+ Paths ( Vec < String > ) ,
2122}
2223
2324#[ derive( Debug , Default , Deserialize , Serialize ) ]
@@ -50,6 +51,19 @@ pub(super) async fn parse_input(
5051 return Ok ( None ) ;
5152 }
5253
54+ // Don't ping if a bors commit is included - send a warning message instead
55+ if event
56+ . issue
57+ . commits ( & ctx. github )
58+ . await
59+ . map_err ( |e| log:: error!( "failed to fetch commits: {:?}" , e) )
60+ . unwrap_or_default ( )
61+ . into_iter ( )
62+ . any ( |commit| commit. commit . author . name == "bors" )
63+ {
64+ return Ok ( Some ( MentionsInput :: HasBorsCommit ) ) ;
65+ }
66+
5367 if let Some ( diff) = event
5468 . issue
5569 . diff ( & ctx. github )
@@ -78,7 +92,7 @@ pub(super) async fn parse_input(
7892 . map ( |( key, _mention) | key. to_string ( ) )
7993 . collect ( ) ;
8094 if !to_mention. is_empty ( ) {
81- return Ok ( Some ( MentionsInput { paths : to_mention } ) ) ;
95+ return Ok ( Some ( MentionsInput :: Paths ( to_mention) ) ) ;
8296 }
8397 }
8498 Ok ( None )
@@ -95,23 +109,30 @@ pub(super) async fn handle_input(
95109 IssueData :: load ( & mut client, & event. issue , MENTIONS_KEY ) . await ?;
96110 // Build the message to post to the issue.
97111 let mut result = String :: new ( ) ;
98- for to_mention in & input. paths {
99- if state. data . paths . iter ( ) . any ( |p| p == to_mention) {
100- // Avoid duplicate mentions.
101- continue ;
102- }
103- let MentionsPathConfig { message, cc } = & config. paths [ to_mention] ;
104- if !result. is_empty ( ) {
105- result. push_str ( "\n \n " ) ;
106- }
107- match message {
108- Some ( m) => result. push_str ( m) ,
109- None => write ! ( result, "Some changes occurred in {to_mention}" ) . unwrap ( ) ,
112+ match input {
113+ MentionsInput :: HasBorsCommit => {
114+ result = config. bors_commit_message . to_string ( ) ;
110115 }
111- if !cc. is_empty ( ) {
112- write ! ( result, "\n \n cc {}" , cc. join( ", " ) ) . unwrap ( ) ;
116+ MentionsInput :: Paths ( paths) => {
117+ for to_mention in & paths {
118+ if state. data . paths . iter ( ) . any ( |p| p == to_mention) {
119+ // Avoid duplicate mentions.
120+ continue ;
121+ }
122+ let MentionsPathConfig { message, cc } = & config. paths [ to_mention] ;
123+ if !result. is_empty ( ) {
124+ result. push_str ( "\n \n " ) ;
125+ }
126+ match message {
127+ Some ( m) => result. push_str ( m) ,
128+ None => write ! ( result, "Some changes occurred in {to_mention}" ) . unwrap ( ) ,
129+ }
130+ if !cc. is_empty ( ) {
131+ write ! ( result, "\n \n cc {}" , cc. join( ", " ) ) . unwrap ( ) ;
132+ }
133+ state. data . paths . push ( to_mention. to_string ( ) ) ;
134+ }
113135 }
114- state. data . paths . push ( to_mention. to_string ( ) ) ;
115136 }
116137 if !result. is_empty ( ) {
117138 event
0 commit comments