@@ -366,12 +366,19 @@ fn create_merge_commit_message(
366
366
match & merge_type {
367
367
// Strip all PR text for try builds, to avoid useless issue pings on the repository.
368
368
// Only keep any lines starting with `CUSTOM_TRY_JOB_PREFIX`.
369
- MergeType :: Try { .. } => {
370
- pr_description = pr_description
371
- . lines ( )
372
- . map ( |l| l. trim ( ) )
373
- . filter ( |l| l. starts_with ( CUSTOM_TRY_JOB_PREFIX ) )
374
- . join ( "\n " ) ;
369
+ MergeType :: Try { try_jobs } => {
370
+ // If we do not have any custom try jobs, keep the ones that might be in the PR
371
+ // description.
372
+ pr_description = if try_jobs. is_empty ( ) {
373
+ pr_description
374
+ . lines ( )
375
+ . map ( |l| l. trim ( ) )
376
+ . filter ( |l| l. starts_with ( CUSTOM_TRY_JOB_PREFIX ) )
377
+ . join ( "\n " )
378
+ } else {
379
+ // If we do have custom jobs, ignore the original description completely
380
+ String :: new ( )
381
+ } ;
375
382
}
376
383
} ;
377
384
@@ -556,6 +563,36 @@ try-job: Bar
556
563
. await ;
557
564
}
558
565
566
+ #[ sqlx:: test]
567
+ async fn try_commit_message_overwrite_try_jobs ( pool : sqlx:: PgPool ) {
568
+ run_test ( pool, async |tester : & mut BorsTester | {
569
+ tester
570
+ . edit_pr ( default_repo_name ( ) , default_pr_number ( ) , |pr| {
571
+ pr. description = r"This is a very good PR.
572
+
573
+ try-job: Foo
574
+ try-job: Bar
575
+ "
576
+ . to_string ( ) ;
577
+ } )
578
+ . await ?;
579
+
580
+ tester. post_comment ( "@bors try jobs=Baz,Baz2" ) . await ?;
581
+ tester. expect_comments ( 1 ) . await ;
582
+
583
+ insta:: assert_snapshot!( tester. get_branch_commit_message( & tester. try_branch( ) ) , @r"
584
+ Auto merge of rust-lang/borstest#1 - pr-1, r=<try>
585
+ PR #1
586
+
587
+
588
+ try-job: Baz
589
+ try-job: Baz2
590
+ " ) ;
591
+ Ok ( ( ) )
592
+ } )
593
+ . await ;
594
+ }
595
+
559
596
#[ sqlx:: test]
560
597
async fn try_merge_branch_history ( pool : sqlx:: PgPool ) {
561
598
let gh = run_test ( pool, async |tester| {
0 commit comments