@@ -152,6 +152,14 @@ pub fn has_changed_since(git_dir: &Path, base: &str, paths: &[&str]) -> bool {
152152 } )
153153}
154154
155+ const LEGACY_BORS_EMAIL : & str = "bors@rust-lang.org" ;
156+
157+ /// Escape characters from the git user e-mail, so that git commands do not interpret it as regex
158+ /// special characters.
159+ fn escape_email_git_regex ( text : & str ) -> String {
160+ text. replace ( "[" , "\\ [" ) . replace ( "]" , "\\ ]" ) . replace ( "." , "\\ ." )
161+ }
162+
155163/// Returns the latest upstream commit that modified `target_paths`, or `None` if no such commit
156164/// was found.
157165fn get_latest_upstream_commit_that_modified_files (
@@ -182,9 +190,15 @@ fn get_latest_upstream_commit_that_modified_files(
182190 "-n1" ,
183191 & upstream,
184192 "--author" ,
185- git_config. git_merge_commit_email ,
193+ & escape_email_git_regex ( git_config. git_merge_commit_email ) ,
186194 ] ) ;
187195
196+ // Also search for legacy bors account, before we accrue enough commits to
197+ // have changes to all relevant file paths done by new bors.
198+ if git_config. git_merge_commit_email != LEGACY_BORS_EMAIL {
199+ git. args ( [ "--author" , LEGACY_BORS_EMAIL ] ) ;
200+ }
201+
188202 if !target_paths. is_empty ( ) {
189203 git. arg ( "--" ) . args ( target_paths) ;
190204 }
@@ -229,11 +243,17 @@ pub fn get_closest_upstream_commit(
229243 git. args ( [
230244 "rev-list" ,
231245 "--author-date-order" ,
232- & format ! ( "--author={}" , config. git_merge_commit_email) ,
246+ & format ! ( "--author={}" , & escape_email_git_regex ( config. git_merge_commit_email) , ) ,
233247 "-n1" ,
234248 base,
235249 ] ) ;
236250
251+ // Also search for legacy bors account, before we accrue enough commits to
252+ // have changes to all relevant file paths done by new bors.
253+ if config. git_merge_commit_email != LEGACY_BORS_EMAIL {
254+ git. args ( [ "--author" , LEGACY_BORS_EMAIL ] ) ;
255+ }
256+
237257 let output = output_result ( & mut git) ?. trim ( ) . to_owned ( ) ;
238258 if output. is_empty ( ) { Ok ( None ) } else { Ok ( Some ( output) ) }
239259}
0 commit comments