11use crate :: api:: { github, ServerResult } ;
22use crate :: github:: {
33 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 ,
55} ;
66use crate :: load:: SiteCtxt ;
77
@@ -44,10 +44,10 @@ async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<gi
4444 & ctxt,
4545 "https://api.github.com/repos/rust-lang/rust" . to_owned ( ) ,
4646 ) ;
47- if push. r#ref != "refs/heads/master" {
47+ if push. r#ref != "refs/heads/master" || push . sender . login != "bors" {
4848 return Ok ( github:: Response ) ;
4949 }
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 ?;
5151 let rollup_pr = match rollup_pr {
5252 Some ( pr) => pr,
5353 None => return Ok ( github:: Response ) ,
@@ -68,7 +68,7 @@ async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<gi
6868 . map ( |( rollup_merge, sha) | {
6969 ROLLUPED_PR_NUMBER
7070 . captures ( & rollup_merge. message )
71- . and_then ( |c| c. get ( 0 ) )
71+ . and_then ( |c| c. get ( 1 ) )
7272 . map ( |m| ( m. as_str ( ) , sha) )
7373 . ok_or_else ( || {
7474 format ! (
@@ -90,37 +90,6 @@ async fn handle_push(ctxt: Arc<SiteCtxt>, push: github::Push) -> ServerResult<gi
9090 Ok ( github:: Response )
9191}
9292
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-
12493async fn handle_issue (
12594 ctxt : Arc < SiteCtxt > ,
12695 issue : github:: Issue ,
0 commit comments