@@ -18,9 +18,21 @@ pub async fn enqueue_unrolled_try_builds<'a>(
1818 client : client:: Client ,
1919 rollup_merges : impl Iterator < Item = & ' a Commit > ,
2020 previous_master : & str ,
21- ) -> Result < Vec < ( & ' a Commit , String ) > , String > {
21+ ) -> Result < Vec < UnrolledCommit < ' a > > , String > {
2222 let mut mapping = Vec :: new ( ) ;
2323 for rollup_merge in rollup_merges {
24+ // Grab the number of the rolled up PR from its commit message
25+ let original_pr_number = ROLLEDUP_PR_NUMBER
26+ . captures ( & rollup_merge. message )
27+ . and_then ( |c| c. get ( 1 ) )
28+ . map ( |m| m. as_str ( ) )
29+ . ok_or_else ( || {
30+ format ! (
31+ "Could not get PR number from message: '{}'" ,
32+ rollup_merge. message
33+ )
34+ } ) ?;
35+
2436 // Fetch the rollup merge commit which should have two parents.
2537 // The first parent is in the chain of rollup merge commits all the way back to `previous_master`.
2638 // The second parent is the head of the PR that was rolled up. We want the second parent.
@@ -45,7 +57,11 @@ pub async fn enqueue_unrolled_try_builds<'a>(
4557
4658 // Merge in the rolled up PR's head commit into the previous master
4759 let sha = client
48- . merge_branch ( "perf-tmp" , rolled_up_head, "merge" )
60+ . merge_branch (
61+ "perf-tmp" ,
62+ rolled_up_head,
63+ & format ! ( "Unrolled build for #{}" , original_pr_number) ,
64+ )
4965 . await
5066 . map_err ( |e| format ! ( "Error merging commit into perf-tmp: {e:?}" ) ) ?;
5167
@@ -55,17 +71,33 @@ pub async fn enqueue_unrolled_try_builds<'a>(
5571 . await
5672 . map_err ( |e| format ! ( "Error updating the try-perf branch: {e:?}" ) ) ?;
5773
58- mapping. push ( ( rollup_merge, sha) ) ;
74+ mapping. push ( UnrolledCommit {
75+ original_pr_number,
76+ rollup_merge,
77+ sha,
78+ } ) ;
5979 // Wait to ensure there's enough time for GitHub to checkout these changes before they are overwritten
6080 tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 15 ) ) . await
6181 }
6282
6383 Ok ( mapping)
6484}
6585
86+ /// A commit representing a rolled up PR as if it had been merged into master directly
87+ pub struct UnrolledCommit < ' a > {
88+ /// The PR number that was rolled up
89+ pub original_pr_number : & ' a str ,
90+ /// The original rollup merge commit
91+ pub rollup_merge : & ' a Commit ,
92+ /// The sha of the new unrolled merge commit
93+ pub sha : String ,
94+ }
95+
6696lazy_static:: lazy_static! {
6797 static ref ROLLUP_PR_NUMBER : regex:: Regex =
6898 regex:: Regex :: new( r#"^Auto merge of #(\d+)"# ) . unwrap( ) ;
99+ static ref ROLLEDUP_PR_NUMBER : regex:: Regex =
100+ regex:: Regex :: new( r#"^Rollup merge of #(\d+)"# ) . unwrap( ) ;
69101}
70102
71103// Gets the pr number for the associated rollup PR message. Returns None if this is not a rollup PR
0 commit comments