mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 08:58:21 +00:00
simplify implementation
This commit is contained in:
parent
d576405223
commit
bcf9bac934
1 changed files with 7 additions and 10 deletions
|
|
@ -33,18 +33,15 @@ pub(crate) fn get_branch_name_repo(
|
|||
) -> Result<String> {
|
||||
scope_time!("get_branch_name_repo");
|
||||
|
||||
let iter = repo.branches(None)?;
|
||||
|
||||
for b in iter {
|
||||
let b = b?;
|
||||
|
||||
if b.0.is_head() {
|
||||
let name = b.0.name()?.unwrap_or("");
|
||||
return Ok(name.into());
|
||||
let head_ref = repo.head().map_err(|e| {
|
||||
if e.code() == git2::ErrorCode::UnbornBranch {
|
||||
Error::NoHead
|
||||
} else {
|
||||
e.into()
|
||||
}
|
||||
}
|
||||
})?;
|
||||
|
||||
Err(Error::NoHead)
|
||||
Ok(bytes2string(head_ref.shorthand_bytes())?)
|
||||
}
|
||||
|
||||
///
|
||||
|
|
|
|||
Loading…
Reference in a new issue