Skip to content

Commit 4d81134

Browse files
committed
Resolve default branch name when branching
1 parent 061b45a commit 4d81134

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/branching.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ impl Context {
1818
return Ok(());
1919
};
2020
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)?;
2223
let prebump_sha = bump_commit.parents[0].sha.clone();
2324
let beta_sha = token.get_ref("heads/beta")?;
2425

src/github.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,17 @@ impl RepositoryClient<'_> {
411411
self.client.without_body().send_with_response::<GitFile>()
412412
}
413413

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.without_body().send_with_response::<Repository>()
423+
}
424+
414425
pub(crate) fn merge_pr(&mut self, pr: u32) -> anyhow::Result<()> {
415426
self.start_new_request()?;
416427
self.client.put(true)?;
@@ -496,6 +507,11 @@ impl GitFile {
496507
}
497508
}
498509

510+
#[derive(Debug, serde::Deserialize)]
511+
pub(crate) struct Repository {
512+
pub(crate) default_branch: String
513+
}
514+
499515
#[derive(Copy, Clone)]
500516
pub(crate) struct CreateTag<'a> {
501517
pub(crate) commit: &'a str,

0 commit comments

Comments
 (0)