summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-04-17 00:05:32 +0200
committerewy <ewy0@protonmail.com>2026-04-17 00:05:32 +0200
commit809b28e3de2ea1bcaecc44a0872df26aa22b3ba2 (patch)
treed9474487501a484379f6a9b6004338a8b46f204b
parent022072ce8bac114ea0a7b94132ed3b8630de2f90 (diff)
fix git stuff failing when no changes
-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...,
))
}