mirror of
https://codeberg.org/Cyborus/forgejo-cli.git
synced 2024-11-10 12:09:33 +01:00
Merge pull request 'enumerate remotes before checking remote tracking branch' (#57) from adjust-remote-guess into main
This commit is contained in:
commit
85ee804919
1 changed files with 15 additions and 15 deletions
30
src/repo.rs
30
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
|
// if there's a remote whose host url matches the one
|
||||||
// specified with `--host`, use that
|
// 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 Some(name) = name {
|
||||||
if let Ok(remote) = local_repo.find_remote(name) {
|
if let Ok(remote) = local_repo.find_remote(name) {
|
||||||
let url_s = std::str::from_utf8(remote.url_bytes())?;
|
let url_s = std::str::from_utf8(remote.url_bytes())?;
|
||||||
|
|
Loading…
Reference in a new issue