fixed sync relating to current branches origin
This commit is contained in:
parent
5b6d1e3795
commit
890d141b9d
|
|
@ -35,7 +35,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
|||
|
||||
[[package]]
|
||||
name = "fast-git-prompt"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"git2",
|
||||
"regex",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "fast-git-prompt"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
description = "A fast git prompt for zsh and bash."
|
||||
license = "MIT"
|
||||
repository = "https://github.com/MasterGordon/fast-git-prompt"
|
||||
|
|
|
|||
|
|
@ -11,10 +11,15 @@ pub struct BranchName {
|
|||
|
||||
impl RenderablePromptPart for BranchName {
|
||||
fn render(self, repo: &Repository) -> Option<String> {
|
||||
let head = match repo.head() {
|
||||
let head_o = match repo.head() {
|
||||
Ok(r) => Some(r),
|
||||
Err(_) => None,
|
||||
}?;
|
||||
};
|
||||
if head_o.is_none() {
|
||||
return Some("HEADLESS".to_string());
|
||||
}
|
||||
let head = head_o?;
|
||||
|
||||
let name = head.name()?;
|
||||
let last = name.split('/').last()?;
|
||||
let head_commit = head.peel_to_commit().unwrap();
|
||||
|
|
|
|||
|
|
@ -14,8 +14,10 @@ impl RenderablePromptPart for BranchSync {
|
|||
fn render(self, repo: &Repository) -> Option<String> {
|
||||
let head = repo.head().ok()?;
|
||||
let head_oid = head.target()?;
|
||||
let name = head.name()?;
|
||||
let last = name.split('/').last()?;
|
||||
let remote = repo
|
||||
.find_branch("origin/main", git2::BranchType::Remote)
|
||||
.find_branch(&format!("origin/{}", last), git2::BranchType::Remote)
|
||||
.ok()?;
|
||||
let remote_oid = remote.get().target()?;
|
||||
let (ahead, behind) = repo.graph_ahead_behind(head_oid, remote_oid).ok()?;
|
||||
|
|
|
|||
Loading…
Reference in New Issue