@@ -18,24 +18,27 @@ pub async fn unroll_rollup(
1818 previous_master : & str ,
1919 rollup_pr_number : u32 ,
2020) -> Result < ( ) , String > {
21+ let format_commit = |s : & str | {
22+ let ( short, _) = s. split_at ( 8 ) ;
23+ format ! ( "[{short}](https://github.com/rust-lang-ci/rust/commit/{s})" )
24+ } ;
2125 let mapping = enqueue_unrolled_try_builds ( ci_client, rollup_merges, previous_master)
2226 . await ?
2327 . into_iter ( )
2428 . fold ( String :: new ( ) , |mut string, c| {
2529 use std:: fmt:: Write ;
26- write ! (
27- & mut string,
28- "|#{pr}|[{commit}](https://github.com/rust-lang-ci/rust/commit/{commit})|\n " ,
29- pr = c. original_pr_number,
30- commit = c. sha
31- )
32- . unwrap ( ) ;
30+ let commit = c. sha . as_deref ( ) . map ( format_commit) . unwrap_or_else ( || {
31+ let head = format_commit ( & c. rolled_up_head ) ;
32+ format ! ( "❌ conflicts merging '{head}' into previous master ❌" )
33+ } ) ;
34+ write ! ( & mut string, "|#{pr}|{commit}|\n " , pr = c. original_pr_number) . unwrap ( ) ;
3335 string
3436 } ) ;
37+ let previous_master = format_commit ( previous_master) ;
3538 let msg =
3639 format ! ( "📌 Perf builds for each rolled up PR:\n \n \
37- |PR# | Perf Build Sha|\n |----|-----|\n \
38- {mapping}\n In the case of a perf regression, \
40+ |PR# | Perf Build Sha|\n |----|: -----: |\n \
41+ {mapping}\n \n *previous master*: {previous_master} \n \ n In the case of a perf regression, \
3942 run the following command for each PR you suspect might be the cause: `@rust-timer build $SHA`") ;
4043 main_repo_client. post_comment ( rollup_pr_number, msg) . await ;
4144 Ok ( ( ) )
@@ -76,35 +79,49 @@ async fn enqueue_unrolled_try_builds<'a>(
7679 "What we thought was a merge commit was not a merge commit. sha: {}" ,
7780 rollup_merge. sha
7881 ) ;
79- let rolled_up_head = & commit. parents [ 1 ] . sha ;
82+ let rolled_up_head = commit. parents [ 1 ] . sha . clone ( ) ;
8083
8184 // Reset perf-tmp to the previous master
8285 client
8386 . update_branch ( "perf-tmp" , previous_master)
8487 . await
8588 . map_err ( |e| format ! ( "Error updating perf-tmp with previous master: {e:?}" ) ) ?;
8689
87- // Merge in the rolled up PR's head commit into the previous master
90+ // Try to merge in the rolled up PR's head commit into the previous master
8891 let sha = client
8992 . merge_branch (
9093 "perf-tmp" ,
91- rolled_up_head,
92- & format ! ( "Unrolled build for #{}" , original_pr_number ) ,
94+ & rolled_up_head,
95+ & format ! ( "Unrolled build for #{original_pr_number}" ) ,
9396 )
9497 . await
9598 . map_err ( |e| {
9699 format ! ( "Error merging #{original_pr_number}'s commit '{rolled_up_head}' into perf-tmp: {e:?}" )
97100 } ) ?;
98101
99- // Force the `try-perf` branch to point to what the perf-tmp branch points to
100- client
101- . update_branch ( "try-perf" , & sha)
102- . await
103- . map_err ( |e| format ! ( "Error updating the try-perf branch: {e:?}" ) ) ?;
102+ // Handle success and merge conflicts
103+ match & sha {
104+ Some ( s) => {
105+ // Force the `try-perf` branch to point to what the perf-tmp branch points to
106+ client
107+ . update_branch ( "try-perf" , s)
108+ . await
109+ . map_err ( |e| format ! ( "Error updating the try-perf branch: {e:?}" ) ) ?;
110+ }
111+ None => {
112+ // Merge conflict
113+ log:: debug!(
114+ "Could not create unrolled commit for #{original_pr_number}. \
115+ Merging the rolled up HEAD '{rolled_up_head}' into the previous master \
116+ '{previous_master}' leads to a merge conflict."
117+ ) ;
118+ }
119+ } ;
104120
105121 mapping. push ( UnrolledCommit {
106122 original_pr_number,
107123 rollup_merge,
124+ rolled_up_head,
108125 sha,
109126 } ) ;
110127 // Wait to ensure there's enough time for GitHub to checkout these changes before they are overwritten
@@ -120,8 +137,10 @@ pub struct UnrolledCommit<'a> {
120137 pub original_pr_number : & ' a str ,
121138 /// The original rollup merge commit
122139 pub rollup_merge : & ' a Commit ,
123- /// The sha of the new unrolled merge commit
124- pub sha : String ,
140+ /// The HEAD commit for the rolled up PR
141+ pub rolled_up_head : String ,
142+ /// The sha of the new unrolled merge commit. `None` when creation failed due to merge conflicts.
143+ pub sha : Option < String > ,
125144}
126145
127146lazy_static:: lazy_static! {
0 commit comments