@@ -17,6 +17,7 @@ use tracing as log;
1717const MENTIONS_KEY : & str = "mentions" ;
1818
1919pub ( super ) struct MentionsInput {
20+ has_bors_commit : bool ,
2021 paths : Vec < String > ,
2122}
2223
@@ -50,6 +51,17 @@ pub(super) async fn parse_input(
5051 return Ok ( None ) ;
5152 }
5253
54+ let has_bors_commit = event. action == IssuesAction :: Opened
55+ && config. bors_commit_message . is_some ( )
56+ && event
57+ . issue
58+ . commits ( & ctx. github )
59+ . await
60+ . map_err ( |e| log:: error!( "failed to fetch commits: {:?}" , e) )
61+ . unwrap_or_default ( )
62+ . into_iter ( )
63+ . any ( |commit| commit. commit . author . name == "bors" ) ;
64+
5365 if let Some ( diff) = event
5466 . issue
5567 . diff ( & ctx. github )
@@ -78,7 +90,10 @@ pub(super) async fn parse_input(
7890 . map ( |( key, _mention) | key. to_string ( ) )
7991 . collect ( ) ;
8092 if !to_mention. is_empty ( ) {
81- return Ok ( Some ( MentionsInput { paths : to_mention } ) ) ;
93+ return Ok ( Some ( MentionsInput {
94+ has_bors_commit,
95+ paths : to_mention,
96+ } ) ) ;
8297 }
8398 }
8499 Ok ( None )
@@ -95,6 +110,14 @@ pub(super) async fn handle_input(
95110 IssueData :: load ( & mut client, & event. issue , MENTIONS_KEY ) . await ?;
96111 // Build the message to post to the issue.
97112 let mut result = String :: new ( ) ;
113+ if input. has_bors_commit {
114+ write ! (
115+ result,
116+ "{}\n " ,
117+ config. bors_commit_message. as_deref( ) . unwrap( )
118+ )
119+ . unwrap ( ) ;
120+ }
98121 for to_mention in & input. paths {
99122 if state. data . paths . iter ( ) . any ( |p| p == to_mention) {
100123 // Avoid duplicate mentions.
@@ -109,6 +132,11 @@ pub(super) async fn handle_input(
109132 None => write ! ( result, "Some changes occurred in {to_mention}" ) . unwrap ( ) ,
110133 }
111134 if !cc. is_empty ( ) {
135+ let cc: Vec < String > = if input. has_bors_commit {
136+ cc. iter ( ) . map ( |s| format ! ( "`{s}`" ) ) . collect ( )
137+ } else {
138+ cc. to_owned ( )
139+ } ;
112140 write ! ( result, "\n \n cc {}" , cc. join( ", " ) ) . unwrap ( ) ;
113141 }
114142 state. data . paths . push ( to_mention. to_string ( ) ) ;
0 commit comments