@@ -18,9 +18,21 @@ pub async fn enqueue_unrolled_try_builds<'a>(
18
18
client : client:: Client ,
19
19
rollup_merges : impl Iterator < Item = & ' a Commit > ,
20
20
previous_master : & str ,
21
- ) -> Result < Vec < ( & ' a Commit , String ) > , String > {
21
+ ) -> Result < Vec < UnrolledCommit < ' a > > , String > {
22
22
let mut mapping = Vec :: new ( ) ;
23
23
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
+
24
36
// Fetch the rollup merge commit which should have two parents.
25
37
// The first parent is in the chain of rollup merge commits all the way back to `previous_master`.
26
38
// 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>(
45
57
46
58
// Merge in the rolled up PR's head commit into the previous master
47
59
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
+ )
49
65
. await
50
66
. map_err ( |e| format ! ( "Error merging commit into perf-tmp: {e:?}" ) ) ?;
51
67
@@ -55,17 +71,33 @@ pub async fn enqueue_unrolled_try_builds<'a>(
55
71
. await
56
72
. map_err ( |e| format ! ( "Error updating the try-perf branch: {e:?}" ) ) ?;
57
73
58
- mapping. push ( ( rollup_merge, sha) ) ;
74
+ mapping. push ( UnrolledCommit {
75
+ original_pr_number,
76
+ rollup_merge,
77
+ sha,
78
+ } ) ;
59
79
// Wait to ensure there's enough time for GitHub to checkout these changes before they are overwritten
60
80
tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 15 ) ) . await
61
81
}
62
82
63
83
Ok ( mapping)
64
84
}
65
85
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
+
66
96
lazy_static:: lazy_static! {
67
97
static ref ROLLUP_PR_NUMBER : regex:: Regex =
68
98
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( ) ;
69
101
}
70
102
71
103
// Gets the pr number for the associated rollup PR message. Returns None if this is not a rollup PR
0 commit comments