diff --git a/src/repo.rs b/src/repo.rs index 6173734..ed61c28 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -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())?;