1+ use crate :: config:: RepositoryConfig ;
2+ use crate :: github:: GithubRepoName ;
3+ use crate :: github:: api:: client:: GithubRepositoryClient ;
4+ use crate :: permissions:: UserPermissions ;
5+ #[ cfg( test) ]
6+ use crate :: tests:: TestSyncMarker ;
17use arc_swap:: ArcSwap ;
28use chrono:: { DateTime , Utc } ;
39pub use command:: CommandParser ;
@@ -8,20 +14,14 @@ pub use handlers::{handle_bors_global_event, handle_bors_repository_event};
814use itertools:: Itertools ;
915use octocrab:: models:: RunId ;
1016use octocrab:: models:: workflows:: Job ;
17+ use regex:: { Regex , RegexBuilder } ;
1118use serde:: Serialize ;
1219use std:: collections:: HashMap ;
1320use std:: fmt;
1421use std:: str:: FromStr ;
15- use std:: sync:: { Arc , RwLock } ;
22+ use std:: sync:: { Arc , LazyLock , RwLock } ;
1623use std:: time:: Duration ;
1724
18- use crate :: config:: RepositoryConfig ;
19- use crate :: github:: GithubRepoName ;
20- use crate :: github:: api:: client:: GithubRepositoryClient ;
21- use crate :: permissions:: UserPermissions ;
22- #[ cfg( test) ]
23- use crate :: tests:: TestSyncMarker ;
24-
2525mod build;
2626mod build_queue;
2727mod command;
@@ -258,16 +258,37 @@ impl FromStr for PullRequestStatus {
258258 }
259259}
260260
261- /// Prefix used to specify custom try jobs in PR descriptions.
262- pub const CUSTOM_TRY_JOB_PREFIX : & str = "try-job:" ;
263-
264261#[ derive( Debug , Clone ) ]
265262pub enum MergeType {
266263 Try { try_jobs : Vec < String > } ,
267264 Auto ,
268265}
269266
267+ /// HTML comment that marks the start of a bors ignore block.
268+ /// The block is called "homu" to maintain compatibility with the old bors implementation
269+ /// (called homu).
270+ const IGNORE_BLOCK_START : & str = "<!-- homu-ignore:start -->" ;
271+ /// HTML comment that marks the end of a bors ignore block.
272+ const IGNORE_BLOCK_END : & str = "<!-- homu-ignore:end -->" ;
273+
274+ /// Returns a string with the given content that will be ignored by bors on GitHub.
275+ pub fn make_text_ignored_by_bors ( text : & str ) -> String {
276+ format ! ( "{IGNORE_BLOCK_START}\n {text}\n {IGNORE_BLOCK_END}" )
277+ }
278+
270279pub fn create_merge_commit_message ( pr : handlers:: PullRequestData , merge_type : MergeType ) -> String {
280+ /// Prefix used to specify custom try jobs in PR descriptions.
281+ const CUSTOM_TRY_JOB_PREFIX : & str = "try-job:" ;
282+
283+ static IGNORE_REGEX : LazyLock < Regex > = LazyLock :: new ( || {
284+ RegexBuilder :: new ( r"<!--\s*homu-ignore:start\s*-->.*?<!--\s*homu-ignore:end\s*-->" )
285+ . multi_line ( true )
286+ . case_insensitive ( true )
287+ . dot_matches_new_line ( true )
288+ . build ( )
289+ . unwrap ( )
290+ } ) ;
291+
271292 let pr_number = pr. number ( ) ;
272293
273294 let reviewer = match & merge_type {
@@ -290,6 +311,7 @@ pub fn create_merge_commit_message(pr: handlers::PullRequestData, merge_type: Me
290311 MergeType :: Try { .. } => String :: new ( ) ,
291312 MergeType :: Auto => pr. github . message . clone ( ) ,
292313 } ;
314+ let pr_description = IGNORE_REGEX . replace_all ( & pr_description, "" ) ;
293315
294316 let mut message = format ! (
295317 r#"Auto merge of #{pr_number} - {pr_label}, r={reviewer}
0 commit comments