1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-04 10:34:55 +02:00
lazygit/pkg/gui/status_panel.go

43 lines
1.0 KiB
Go
Raw Normal View History

2018-08-13 12:26:02 +02:00
package gui
2018-06-02 00:35:49 +02:00
import (
2018-08-06 07:37:14 +02:00
"fmt"
2018-06-02 00:35:49 +02:00
2018-08-06 07:37:14 +02:00
"github.com/fatih/color"
"github.com/jesseduffield/gocui"
2018-08-13 13:16:21 +02:00
"github.com/jesseduffield/lazygit/pkg/utils"
2018-06-02 00:35:49 +02:00
)
2018-08-13 13:16:21 +02:00
func (gui *Gui) refreshStatus(g *gocui.Gui) error {
2018-08-06 07:37:14 +02:00
v, err := g.View("status")
if err != nil {
panic(err)
}
// for some reason if this isn't wrapped in an update the clear seems to
// be applied after the other things or something like that; the panel's
// contents end up cleared
g.Update(func(*gocui.Gui) error {
v.Clear()
2018-08-13 13:16:21 +02:00
pushables, pullables := gui.GitCommand.UpstreamDifferenceCount()
2018-08-06 07:37:14 +02:00
fmt.Fprint(v, "↑"+pushables+"↓"+pullables)
2018-08-13 13:16:21 +02:00
branches := gui.State.Branches
if err := gui.updateHasMergeConflictStatus(); err != nil {
2018-08-06 07:37:14 +02:00
return err
}
2018-08-13 13:16:21 +02:00
if gui.State.HasMergeConflicts {
fmt.Fprint(v, utils.ColoredString(" (merging)", color.FgYellow))
2018-08-06 07:37:14 +02:00
}
2018-08-11 07:09:37 +02:00
2018-08-06 07:37:14 +02:00
if len(branches) == 0 {
return nil
}
branch := branches[0]
2018-08-13 13:16:21 +02:00
name := utils.ColoredString(branch.Name, branch.GetColor())
repo := utils.GetCurrentRepoName()
2018-08-11 07:09:37 +02:00
fmt.Fprint(v, " "+repo+" → "+name)
2018-08-06 07:37:14 +02:00
return nil
})
2018-06-02 00:35:49 +02:00
2018-08-06 07:37:14 +02:00
return nil
2018-06-02 00:35:49 +02:00
}