File tree Expand file tree Collapse file tree 4 files changed +29
-11
lines changed Expand file tree Collapse file tree 4 files changed +29
-11
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ set -euo pipefail
7
7
IFS=$' \n\t '
8
8
9
9
RUSTC_REPO=" https://github.com/rust-lang/rust"
10
- RUSTC_DEFAULT_BRANCH=" master"
11
10
12
11
# CDN to download CI artifacts from.
13
12
DOWNLOAD_BASE=" https://ci-artifacts.rust-lang.org/rustc-builds"
@@ -47,17 +46,17 @@ override_commit="$2"
47
46
48
47
# Nightly is on the default branch
49
48
if [[ " ${channel} " = " nightly" ]]; then
50
- branch=" ${RUSTC_DEFAULT_BRANCH} "
49
+ branch=" HEAD "
51
50
else
52
- branch=" ${channel} "
51
+ branch=" refs/heads/ ${channel} "
53
52
fi
54
53
55
54
echo " ==> overriding files to force promote-release to run"
56
55
mc cp " /src/local/channel-rust-${channel} .toml" " local/static/dist/channel-rust-${channel} .toml" > /dev/null
57
56
58
57
if [[ " ${override_commit} " = " " ]]; then
59
58
echo " ==> detecting the last rustc commit on branch ${branch} "
60
- commit=" $( git ls-remote " ${RUSTC_REPO} " | grep " refs/heads/ ${branch} " | awk ' {print($1)}' ) "
59
+ commit=" $( git ls-remote " ${RUSTC_REPO} " " ${branch} " | awk ' {print($1)}' ) "
61
60
else
62
61
echo " =>> using overridden commit ${override_commit} "
63
62
commit=" ${override_commit} "
Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ impl Context {
18
18
return Ok ( ( ) ) ;
19
19
} ;
20
20
let mut token = github. token ( "rust-lang/rust" ) ?;
21
- let bump_commit = branchpoint ( & mut token, "master" ) ?;
21
+ let repo = token. repository ( ) ?;
22
+ let bump_commit = branchpoint ( & mut token, & repo. default_branch ) ?;
22
23
let prebump_sha = bump_commit. parents [ 0 ] . sha . clone ( ) ;
23
24
let beta_sha = token. get_ref ( "heads/beta" ) ?;
24
25
Original file line number Diff line number Diff line change @@ -411,6 +411,19 @@ impl RepositoryClient<'_> {
411
411
self . client . without_body ( ) . send_with_response :: < GitFile > ( )
412
412
}
413
413
414
+ /// Returns information about the current repository
415
+ pub ( crate ) fn repository ( & mut self ) -> anyhow:: Result < Repository > {
416
+ self . start_new_request ( ) ?;
417
+ self . client . get ( true ) ?;
418
+ self . client . url ( & format ! (
419
+ "https://api.github.com/repos/{repo}" ,
420
+ repo = self . repo,
421
+ ) ) ?;
422
+ self . client
423
+ . without_body ( )
424
+ . send_with_response :: < Repository > ( )
425
+ }
426
+
414
427
pub ( crate ) fn merge_pr ( & mut self , pr : u32 ) -> anyhow:: Result < ( ) > {
415
428
self . start_new_request ( ) ?;
416
429
self . client . put ( true ) ?;
@@ -496,6 +509,11 @@ impl GitFile {
496
509
}
497
510
}
498
511
512
+ #[ derive( Debug , serde:: Deserialize ) ]
513
+ pub ( crate ) struct Repository {
514
+ pub ( crate ) default_branch : String ,
515
+ }
516
+
499
517
#[ derive( Copy , Clone ) ]
500
518
pub ( crate ) struct CreateTag < ' a > {
501
519
pub ( crate ) commit : & ' a str ,
Original file line number Diff line number Diff line change @@ -104,12 +104,6 @@ impl Context {
104
104
return Ok ( commit) ;
105
105
}
106
106
107
- let git_ref = match self . config . channel {
108
- Channel :: Nightly => "refs/heads/master" ,
109
- Channel :: Beta => "refs/heads/beta" ,
110
- Channel :: Stable => "refs/heads/stable" ,
111
- } ;
112
-
113
107
// git2 requires a git repository to be able to connect to a remote and fetch metadata, so
114
108
// this creates an empty repository in a temporary directory. It will be deleted once the
115
109
// function returns.
@@ -119,6 +113,12 @@ impl Context {
119
113
let mut remote = repo. remote ( "origin" , & self . config . repository ) ?;
120
114
remote. connect ( git2:: Direction :: Fetch ) ?;
121
115
116
+ let git_ref = match self . config . channel {
117
+ Channel :: Nightly => remote. default_branch ( ) ?. as_str ( ) . unwrap ( ) . to_string ( ) ,
118
+ Channel :: Beta => "refs/heads/beta" . to_string ( ) ,
119
+ Channel :: Stable => "refs/heads/stable" . to_string ( ) ,
120
+ } ;
121
+
122
122
for head in remote. list ( ) ? {
123
123
if head. name ( ) == git_ref {
124
124
return Ok ( hex:: encode ( head. oid ( ) . as_bytes ( ) ) ) ;
You can’t perform that action at this time.
0 commit comments