summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git/git.go3
-rw-r--r--menu/source.go16
2 files changed, 14 insertions, 5 deletions
diff --git a/git/git.go b/git/git.go
index 36b72b1..0f6c8b2 100644
--- a/git/git.go
+++ b/git/git.go
@@ -77,6 +77,9 @@ func (g *gitMod) Diff(source *model.Source) (int, int, int, error) {
insertions := 0
deletions := 0
for _, s := range split {
+ if strings.TrimSpace(s) == "" {
+ return 0, 0, 0, nil
+ }
var e error
pt := strings.Split(strings.TrimSpace(s), " ")
num, e := strconv.Atoi(pt[0])
diff --git a/menu/source.go b/menu/source.go
index efe4e0a..913c1ce 100644
--- a/menu/source.go
+++ b/menu/source.go
@@ -100,12 +100,18 @@ var (
)
func Git(info *model.GitInfo) string {
-
- return GitInfoStyle.Render(lipgloss.JoinHorizontal(lipgloss.Left,
+ var parts = []string{
" ",
info.Branch,
- GitAddStyle.Render("+"+strconv.Itoa(info.Insertions)),
- GitRemoveStyle.Render("-"+strconv.Itoa(info.Deletions)),
- GitChangeStyle.Render("~"+strconv.Itoa(info.Changes)),
+ }
+
+ if info.Insertions > 0 {
+ parts = append(parts, GitAddStyle.Render("+"+strconv.Itoa(info.Insertions)))
+ parts = append(parts, GitRemoveStyle.Render("-"+strconv.Itoa(info.Deletions)))
+ parts = append(parts, GitChangeStyle.Render("~"+strconv.Itoa(info.Changes)))
+ }
+
+ return GitInfoStyle.Render(lipgloss.JoinHorizontal(lipgloss.Left,
+ parts...,
))
}