Skip to content

Commit 4f80282

Browse files
committed
Overwrite custom try jobs instead of appending to them
1 parent 1f250a5 commit 4f80282

File tree

1 file changed

+43
-6
lines changed

1 file changed

+43
-6
lines changed

src/bors/handlers/trybuild.rs

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,19 @@ fn create_merge_commit_message(
366366
match &merge_type {
367367
// Strip all PR text for try builds, to avoid useless issue pings on the repository.
368368
// 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+
};
375382
}
376383
};
377384

@@ -556,6 +563,36 @@ try-job: Bar
556563
.await;
557564
}
558565

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+
559596
#[sqlx::test]
560597
async fn try_merge_branch_history(pool: sqlx::PgPool) {
561598
let gh = run_test(pool, async |tester| {

0 commit comments

Comments
 (0)