@@ -25,96 +25,106 @@ pub async fn handle_github(
25
25
ctxt : Arc < SiteCtxt > ,
26
26
) -> ServerResult < github:: Response > {
27
27
log:: info!( "handle_github({:?})" , request) ;
28
- if request. comment . body . contains ( " homu: " ) {
29
- if let Some ( sha) = parse_homu_comment ( & request. comment . body ) . await {
30
- enqueue_sha ( request. issue , & ctxt, sha) . await ?;
28
+ match request {
29
+ github:: Request :: Issue { issue, comment } => handle_issue ( ctxt, issue, comment) . await ,
30
+ }
31
+ }
32
+
33
+ async fn handle_issue (
34
+ ctxt : Arc < SiteCtxt > ,
35
+ issue : github:: Issue ,
36
+ comment : github:: Comment ,
37
+ ) -> ServerResult < github:: Response > {
38
+ if comment. body . contains ( " homu: " ) {
39
+ if let Some ( sha) = parse_homu_comment ( & comment. body ) . await {
40
+ enqueue_sha ( issue, & ctxt, sha) . await ?;
31
41
return Ok ( github:: Response ) ;
32
42
}
33
43
}
34
44
35
- if !request . comment . body . contains ( "@rust-timer " ) {
36
- return Ok ( github :: Response ) ;
45
+ if comment. body . contains ( "@rust-timer " ) {
46
+ return handle_rust_timer ( ctxt , comment , issue ) . await ;
37
47
}
38
48
39
- if request. comment . author_association != github:: Association :: Owner
40
- && !get_authorized_users ( )
41
- . await ?
42
- . contains ( & request. comment . user . id )
49
+ Ok ( github:: Response )
50
+ }
51
+
52
+ async fn handle_rust_timer (
53
+ ctxt : Arc < SiteCtxt > ,
54
+ comment : github:: Comment ,
55
+ issue : github:: Issue ,
56
+ ) -> ServerResult < github:: Response > {
57
+ if comment. author_association != github:: Association :: Owner
58
+ && !get_authorized_users ( ) . await ?. contains ( & comment. user . id )
43
59
{
44
60
post_comment (
45
61
& ctxt. config ,
46
- request . issue . number ,
62
+ issue. number ,
47
63
"Insufficient permissions to issue commands to rust-timer." ,
48
64
)
49
65
. await ;
50
66
return Ok ( github:: Response ) ;
51
67
}
52
68
53
- if let Some ( captures) = BODY_QUEUE . captures ( & request . comment . body ) {
69
+ if let Some ( captures) = BODY_QUEUE . captures ( & comment. body ) {
54
70
let include = captures. get ( 1 ) . map ( |v| v. as_str ( ) ) ;
55
71
let exclude = captures. get ( 2 ) . map ( |v| v. as_str ( ) ) ;
56
72
let runs = captures. get ( 3 ) . and_then ( |v| v. as_str ( ) . parse :: < i32 > ( ) . ok ( ) ) ;
57
73
{
58
74
let conn = ctxt. conn ( ) . await ;
59
- conn. queue_pr ( request. issue . number , include, exclude, runs)
60
- . await ;
75
+ conn. queue_pr ( issue. number , include, exclude, runs) . await ;
61
76
}
62
77
post_comment (
63
78
& ctxt. config ,
64
- request . issue . number ,
79
+ issue. number ,
65
80
"Awaiting bors try build completion.
66
81
67
82
@rustbot label: +S-waiting-on-perf" ,
68
83
)
69
84
. await ;
70
85
return Ok ( github:: Response ) ;
71
86
}
72
-
73
- if let Some ( captures) = BODY_TRY_COMMIT . captures ( & request. comment . body ) {
87
+ if let Some ( captures) = BODY_TRY_COMMIT . captures ( & comment. body ) {
74
88
if let Some ( commit) = captures. get ( 1 ) . map ( |c| c. as_str ( ) . to_owned ( ) ) {
75
89
let include = captures. get ( 2 ) . map ( |v| v. as_str ( ) ) ;
76
90
let exclude = captures. get ( 3 ) . map ( |v| v. as_str ( ) ) ;
77
91
let runs = captures. get ( 4 ) . and_then ( |v| v. as_str ( ) . parse :: < i32 > ( ) . ok ( ) ) ;
78
92
let commit = commit. trim_start_matches ( "https://github.com/rust-lang/rust/commit/" ) ;
79
93
{
80
94
let conn = ctxt. conn ( ) . await ;
81
- conn. queue_pr ( request. issue . number , include, exclude, runs)
82
- . await ;
95
+ conn. queue_pr ( issue. number , include, exclude, runs) . await ;
83
96
}
84
- enqueue_sha ( request . issue , & ctxt, commit. to_owned ( ) ) . await ?;
97
+ enqueue_sha ( issue, & ctxt, commit. to_owned ( ) ) . await ?;
85
98
return Ok ( github:: Response ) ;
86
99
}
87
100
}
88
-
89
- for rollup_merge in extract_make_pr_for ( & request. comment . body ) {
101
+ for rollup_merge in extract_make_pr_for ( & comment. body ) {
90
102
let client = reqwest:: Client :: new ( ) ;
91
103
pr_and_try_for_rollup (
92
104
& client,
93
105
ctxt. clone ( ) ,
94
- & request . issue . repository_url ,
106
+ & issue. repository_url ,
95
107
& rollup_merge,
96
- & request . comment . html_url ,
108
+ & comment. html_url ,
97
109
)
98
110
. await
99
111
. map_err ( |e| format ! ( "{:?}" , e) ) ?;
100
112
}
101
-
102
- for rollup_merge in extract_update_pr_for ( & request. comment . body ) {
113
+ for rollup_merge in extract_update_pr_for ( & comment. body ) {
103
114
// This just creates or updates the branch for this merge commit.
104
115
// Intended for resolving the race condition of master merging in
105
116
// between us updating the commit and merging things.
106
117
let client = reqwest:: Client :: new ( ) ;
107
- let branch = branch_for_rollup ( & client, & ctxt, & request . issue . repository_url , rollup_merge)
118
+ let branch = branch_for_rollup ( & client, & ctxt, & issue. repository_url , rollup_merge)
108
119
. await
109
120
. map_err ( |e| e. to_string ( ) ) ?;
110
121
post_comment (
111
122
& ctxt. config ,
112
- request . issue . number ,
123
+ issue. number ,
113
124
& format ! ( "Master base SHA: {}" , branch. master_base_sha) ,
114
125
)
115
126
. await ;
116
127
}
117
-
118
128
Ok ( github:: Response )
119
129
}
120
130
0 commit comments