1
1
use crate :: api:: { github, ServerResult } ;
2
2
use crate :: github:: {
3
3
branch_for_rollup, client, enqueue_sha, enqueue_unrolled_try_builds, get_authorized_users,
4
- parse_homu_comment, pr_and_try_for_rollup,
4
+ parse_homu_comment, pr_and_try_for_rollup, rollup_pr ,
5
5
} ;
6
6
use crate :: load:: SiteCtxt ;
7
7
@@ -44,10 +44,10 @@ async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<gi
44
44
& ctxt,
45
45
"https://api.github.com/repos/rust-lang/rust" . to_owned ( ) ,
46
46
) ;
47
- if push. r#ref != "refs/heads/master" {
47
+ if push. r#ref != "refs/heads/master" || push . sender . login != "bors" {
48
48
return Ok ( github:: Response ) ;
49
49
}
50
- let rollup_pr = rollup_pr ( & main_repo_client, & push) . await ?;
50
+ let rollup_pr = rollup_pr ( & main_repo_client, & push. head_commit . message ) . await ?;
51
51
let rollup_pr = match rollup_pr {
52
52
Some ( pr) => pr,
53
53
None => return Ok ( github:: Response ) ,
@@ -68,7 +68,7 @@ async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<gi
68
68
. map ( |( rollup_merge, sha) | {
69
69
ROLLUPED_PR_NUMBER
70
70
. captures ( & rollup_merge. message )
71
- . and_then ( |c| c. get ( 0 ) )
71
+ . and_then ( |c| c. get ( 1 ) )
72
72
. map ( |m| ( m. as_str ( ) , sha) )
73
73
. ok_or_else ( || {
74
74
format ! (
@@ -90,37 +90,6 @@ async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<gi
90
90
Ok ( github:: Response )
91
91
}
92
92
93
- // Gets the pr number for the associated rollup PR. Returns None if this is not a rollup PR
94
- async fn rollup_pr ( client : & client:: Client , push : & github:: Push ) -> ServerResult < Option < u32 > > {
95
- macro_rules! get {
96
- ( $x: expr) => {
97
- match $x {
98
- Some ( x) => x,
99
- None => return Ok ( None ) ,
100
- }
101
- } ;
102
- }
103
- let is_bors =
104
- push. sender . login == "bors" && push. head_commit . message . starts_with ( "Auto merge of" ) ;
105
-
106
- if !is_bors {
107
- return Ok ( None ) ;
108
- }
109
- let captures = get ! ( ROLLUP_PR_NUMBER . captures( & push. head_commit. message) ) ;
110
- let number = get ! ( get!( captures. get( 0 ) ) . as_str( ) . parse:: <u64 >( ) . ok( ) ) ;
111
-
112
- let issue = client
113
- . get_issue ( number)
114
- . await
115
- . map_err ( |e| format ! ( "Error fetching PR #{number} {e:?}" ) ) ?;
116
-
117
- Ok ( issue
118
- . labels
119
- . iter ( )
120
- . any ( |l| l. name == "rollup" )
121
- . then ( || issue. number ) )
122
- }
123
-
124
93
async fn handle_issue (
125
94
ctxt : Arc < SiteCtxt > ,
126
95
issue : github:: Issue ,
0 commit comments