Skip to content

Commit

Permalink
Decouple stash entries from clean flag (#67)
Browse files Browse the repository at this point in the history
Since now the clean flag is indepdendent from the number of
stashed entries, we need to show the stash count, even if the
working tree is clean.

Fix #66
  • Loading branch information
arl authored Mar 18, 2022
1 parent 22e1642 commit d79bab3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tmux/formater.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,19 @@ func (f *Formater) currentRef() {
}

func (f *Formater) flags() {
var flags []string
if f.st.IsClean {
f.clear()
fmt.Fprintf(&f.b, "%s%s", f.Styles.Clean, f.Symbols.Clean)
if f.st.NumStashed != 0 {
flags = append(flags,
fmt.Sprintf("%s%s%d", f.Styles.Stashed, f.Symbols.Stashed, f.st.NumStashed))
}

flags = append(flags, fmt.Sprintf("%s%s", f.Styles.Clean, f.Symbols.Clean))
f.clear()
f.b.WriteString(strings.Join(flags, " "))
return
}

var flags []string

if f.st.NumStaged != 0 {
flags = append(flags,
fmt.Sprintf("%s%s%d", f.Styles.Staged, f.Symbols.Staged, f.st.NumStaged))
Expand Down
18 changes: 18 additions & 0 deletions tmux/formater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@ func TestFlags(t *testing.T) {
},
want: "StyleClear" + "StyleCleanSymbolClean",
},
{
name: "stash + clean flag",
styles: styles{
Clear: "StyleClear",
Clean: "StyleClean",
Stashed: "StyleStash",
},
symbols: symbols{
Clean: "SymbolClean",
Stashed: "SymbolStash",
},
layout: []string{"branch", "..", "remote", " - ", "flags"},
st: &gitstatus.Status{
IsClean: true,
NumStashed: 1,
},
want: "StyleClearStyleStashSymbolStash1 StyleCleanSymbolClean",
},
{
name: "mixed flags",
styles: styles{
Expand Down

0 comments on commit d79bab3

Please sign in to comment.