@@ -9,6 +9,11 @@ use reqwest::Client;
9
9
use std:: fmt:: Write ;
10
10
use std:: str:: FromStr ;
11
11
12
+ /// This is the repository where the commits will be created.
13
+ const WORK_REPO : & str = "rustbot/rust" ;
14
+ /// This is the repository where the PR will be created.
15
+ const DEST_REPO : & str = "rust-lang/rust" ;
16
+ /// This is the branch in `WORK_REPO` to create the commits.
12
17
const BRANCH_NAME : & str = "docs-update" ;
13
18
14
19
const SUBMODULES : & [ & str ] = & [
@@ -56,16 +61,19 @@ pub async fn handle_job() -> Result<()> {
56
61
57
62
async fn docs_update ( ) -> Result < ( ) > {
58
63
let gh = GithubClient :: new_with_default_token ( Client :: new ( ) ) ;
59
- let repo = gh. repository ( "rust-lang/rust" ) . await ?;
64
+ let work_repo = gh. repository ( WORK_REPO ) . await ?;
65
+ work_repo
66
+ . merge_upstream ( & gh, & work_repo. default_branch )
67
+ . await ?;
60
68
61
- let updates = get_submodule_updates ( & gh, & repo ) . await ?;
69
+ let updates = get_submodule_updates ( & gh, & work_repo ) . await ?;
62
70
if updates. is_empty ( ) {
63
71
tracing:: trace!( "no updates this week?" ) ;
64
72
return Ok ( ( ) ) ;
65
73
}
66
74
67
- create_commit ( & gh, & repo , & updates) . await ?;
68
- create_pr ( & gh, & repo , & updates) . await ?;
75
+ create_commit ( & gh, & work_repo , & updates) . await ?;
76
+ create_pr ( & gh, & updates) . await ?;
69
77
Ok ( ( ) )
70
78
}
71
79
@@ -176,14 +184,17 @@ async fn create_commit(
176
184
Ok ( ( ) )
177
185
}
178
186
179
- async fn create_pr ( gh : & GithubClient , rust_repo : & Repository , updates : & [ Update ] ) -> Result < ( ) > {
187
+ async fn create_pr ( gh : & GithubClient , updates : & [ Update ] ) -> Result < ( ) > {
188
+ let dest_repo = gh. repository ( DEST_REPO ) . await ?;
180
189
let mut body = String :: new ( ) ;
181
190
for update in updates {
182
191
write ! ( body, "{}\n " , update. pr_body) . unwrap ( ) ;
183
192
}
184
193
185
- let pr = rust_repo
186
- . new_pr ( gh, TITLE , BRANCH_NAME , & rust_repo. default_branch , & body)
194
+ let username = WORK_REPO . split ( '/' ) . next ( ) . unwrap ( ) ;
195
+ let head = format ! ( "{username}:{BRANCH_NAME}" ) ;
196
+ let pr = dest_repo
197
+ . new_pr ( gh, TITLE , & head, & dest_repo. default_branch , & body)
187
198
. await ?;
188
199
tracing:: debug!( "created PR {}" , pr. html_url) ;
189
200
Ok ( ( ) )
0 commit comments