enumerate remotes before checking remote tracking branch

This commit is contained in:
Cyborus 2024-05-10 17:49:35 -04:00
parent 8465a4a857
commit 3dec5f9ebe
No known key found for this signature in database

View file

@ -127,21 +127,6 @@ impl RepoInfo {
}
}
// if the current branch is tracking a remote branch, use that remote
if name.is_none() {
let head = local_repo.head()?;
let branch_name = head.name().ok_or_else(|| eyre!("branch name not UTF-8"))?;
tmp = local_repo.branch_upstream_remote(branch_name).ok();
name = tmp
.as_ref()
.map(|remote| {
remote
.as_str()
.ok_or_else(|| eyre!("remote name not UTF-8"))
})
.transpose()?;
}
// if there's a remote whose host url matches the one
// specified with `--host`, use that
//
@ -169,6 +154,21 @@ impl RepoInfo {
}
}
// if the current branch is tracking a remote branch, use that remote
if name.is_none() {
let head = local_repo.head()?;
let branch_name = head.name().ok_or_else(|| eyre!("branch name not UTF-8"))?;
tmp = local_repo.branch_upstream_remote(branch_name).ok();
name = tmp
.as_ref()
.map(|remote| {
remote
.as_str()
.ok_or_else(|| eyre!("remote name not UTF-8"))
})
.transpose()?;
}
if let Some(name) = name {
if let Ok(remote) = local_repo.find_remote(name) {
let url_s = std::str::from_utf8(remote.url_bytes())?;