Skip to content

Commit 2647669

Browse files
committed
Resolve default branch name when doing a release
1 parent 4d81134 commit 2647669

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,6 @@ impl Context {
104104
return Ok(commit);
105105
}
106106

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-
113107
// git2 requires a git repository to be able to connect to a remote and fetch metadata, so
114108
// this creates an empty repository in a temporary directory. It will be deleted once the
115109
// function returns.
@@ -119,6 +113,12 @@ impl Context {
119113
let mut remote = repo.remote("origin", &self.config.repository)?;
120114
remote.connect(git2::Direction::Fetch)?;
121115

116+
let git_ref = match self.config.channel {
117+
Channel::Nightly => format!("refs/heads/{}", remote.default_branch()?.as_str().unwrap()),
118+
Channel::Beta => "refs/heads/beta".to_string(),
119+
Channel::Stable => "refs/heads/stable".to_string(),
120+
};
121+
122122
for head in remote.list()? {
123123
if head.name() == git_ref {
124124
return Ok(hex::encode(head.oid().as_bytes()));

0 commit comments

Comments
 (0)