mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-17 00:18:05 +02:00
WIP Show both ahead and behind
This commit is contained in:
committed by
Jesse Duffield
parent
6eaece3696
commit
6d2ec43596
@ -125,6 +125,7 @@ func (self *BranchLoader) Load(reflogCommits []*models.Commit, existingMainBranc
|
|||||||
return b.Name == branch.Name
|
return b.Name == branch.Name
|
||||||
}); found {
|
}); found {
|
||||||
branch.BehindBaseBranch.Store(oldBranch.BehindBaseBranch.Load())
|
branch.BehindBaseBranch.Store(oldBranch.BehindBaseBranch.Load())
|
||||||
|
branch.AheadOfBaseBranch.Store(oldBranch.AheadOfBaseBranch.Load())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,12 +154,15 @@ func (self *BranchLoader) Load(reflogCommits []*models.Commit, existingMainBranc
|
|||||||
if len(aheadBehindStr) != 2 {
|
if len(aheadBehindStr) != 2 {
|
||||||
return errors.New("unexpected output from git rev-list")
|
return errors.New("unexpected output from git rev-list")
|
||||||
}
|
}
|
||||||
|
if ahead, err := strconv.Atoi(aheadBehindStr[0]); err == nil {
|
||||||
if behind, err := strconv.Atoi(aheadBehindStr[1]); err == nil {
|
if behind, err := strconv.Atoi(aheadBehindStr[1]); err == nil {
|
||||||
|
branch.AheadOfBaseBranch.Store(int32(ahead))
|
||||||
branch.BehindBaseBranch.Store(int32(behind))
|
branch.BehindBaseBranch.Store(int32(behind))
|
||||||
renderFunc()
|
renderFunc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
@ -36,6 +36,12 @@ type Branch struct {
|
|||||||
// determined yet, or up to date with base branch. (We don't need to
|
// determined yet, or up to date with base branch. (We don't need to
|
||||||
// distinguish the two, as we don't draw anything in both cases.)
|
// distinguish the two, as we don't draw anything in both cases.)
|
||||||
BehindBaseBranch atomic.Int32
|
BehindBaseBranch atomic.Int32
|
||||||
|
|
||||||
|
// How far our branch is ahead of its base branch. 0 means either not
|
||||||
|
// determined yet, or there are no commits on this branch yet, or the branch
|
||||||
|
// is already merged. (We don't need to distinguish these, as we don't draw
|
||||||
|
// anything in all these cases.)
|
||||||
|
AheadOfBaseBranch atomic.Int32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Branch) FullRefName() string {
|
func (b *Branch) FullRefName() string {
|
||||||
|
@ -172,11 +172,19 @@ func BranchStatus(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if v := branch.BehindBaseBranch.Load(); v != 0 {
|
ahead := branch.AheadOfBaseBranch.Load()
|
||||||
|
behind := branch.BehindBaseBranch.Load()
|
||||||
|
if ahead != 0 || behind != 0 {
|
||||||
if result != "" {
|
if result != "" {
|
||||||
result += " "
|
result += " "
|
||||||
}
|
}
|
||||||
result += style.FgCyan.Sprintf("↓%d", v)
|
if ahead != 0 && behind != 0 {
|
||||||
|
result += style.FgCyan.Sprintf("↓%d↑%d", behind, ahead)
|
||||||
|
} else if behind != 0 {
|
||||||
|
result += style.FgCyan.Sprintf("↓%d", behind)
|
||||||
|
} else {
|
||||||
|
result += style.FgCyan.Sprintf("↑%d", ahead)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
Reference in New Issue
Block a user