@@ -16,8 +16,9 @@ use tracing as log;
16
16
17
17
const MENTIONS_KEY : & str = "mentions" ;
18
18
19
- pub ( super ) struct MentionsInput {
20
- paths : Vec < String > ,
19
+ pub ( super ) enum MentionsInput {
20
+ HasBorsCommit ,
21
+ Paths ( Vec < String > ) ,
21
22
}
22
23
23
24
#[ derive( Debug , Default , Deserialize , Serialize ) ]
@@ -50,6 +51,19 @@ pub(super) async fn parse_input(
50
51
return Ok ( None ) ;
51
52
}
52
53
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
+
53
67
if let Some ( diff) = event
54
68
. issue
55
69
. diff ( & ctx. github )
@@ -78,7 +92,7 @@ pub(super) async fn parse_input(
78
92
. map ( |( key, _mention) | key. to_string ( ) )
79
93
. collect ( ) ;
80
94
if !to_mention. is_empty ( ) {
81
- return Ok ( Some ( MentionsInput { paths : to_mention } ) ) ;
95
+ return Ok ( Some ( MentionsInput :: Paths ( to_mention) ) ) ;
82
96
}
83
97
}
84
98
Ok ( None )
@@ -95,23 +109,30 @@ pub(super) async fn handle_input(
95
109
IssueData :: load ( & mut client, & event. issue , MENTIONS_KEY ) . await ?;
96
110
// Build the message to post to the issue.
97
111
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 ( ) ;
110
115
}
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
+ }
113
135
}
114
- state. data . paths . push ( to_mention. to_string ( ) ) ;
115
136
}
116
137
if !result. is_empty ( ) {
117
138
event
0 commit comments