Issue 32/branch format (#38)

* format/tmux: add failing test for issue 32

As exposed in the added failing test, reproducing the issue 32, the
branch style only affect the branch symbol whereas it should affect both
affect the symbol and the branch name.

* format/tmux: branch style now affects both branch symbol+name

Fixes #32

* Fix tests and adapt for new behavior
This commit is contained in:
Aurélien Rainone 2020-09-02 02:37:38 +02:00 committed by GitHub
parent 845f4165fe
commit 06654727b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 6 deletions

View file

@ -240,12 +240,12 @@ func (f *Formater) currentRef() {
f.clear()
if f.st.IsDetached {
fmt.Fprintf(&f.b, "%s%s", f.Symbols.HashPrefix, f.st.HEAD)
fmt.Fprintf(&f.b, "%s%s%s", f.Styles.Branch, f.Symbols.HashPrefix, f.st.HEAD)
return
}
fmt.Fprintf(&f.b, "%s",
fmt.Fprintf(&f.b, "%s%s", f.Styles.Branch,
truncateBranchName(f.st.LocalBranch, f.Options.BranchMaxLen, false))
}

View file

@ -256,7 +256,7 @@ func TestFormat(t *testing.T) {
},
},
want: clear + "StyleBranchSymbolBranch" +
clear + "Local" + ".." +
clear + "StyleBranch" + "Local" + ".." +
clear + "StyleRemoteRemote" +
clear + " - " +
clear + "StyleModSymbolMod2",
@ -283,7 +283,7 @@ func TestFormat(t *testing.T) {
},
},
want: clear + "StyleBranchSymbolBranch" +
clear + "Local" + " ~~ " +
clear + "StyleBranch" + "Local" + " ~~ " +
clear + "StyleModSymbolMod2",
},
{
@ -346,10 +346,27 @@ func TestFormat(t *testing.T) {
},
},
want: clear + "StyleBranch" + "SymbolBranch" +
clear + "branch..." + " " +
clear + "StyleBranch" + "branch..." + " " +
clear + "StyleRemote" + "remote/branch..." +
clear,
},
{
name: "issue-32",
styles: styles{
Branch: "StyleBranch",
},
symbols: symbols{
Branch: "SymbolBranch",
},
layout: []string{"branch"},
st: &gitstatus.Status{
Porcelain: gitstatus.Porcelain{
LocalBranch: "branchName",
},
},
want: clear + "StyleBranch" + "SymbolBranch" +
clear + "StyleBranch" + "branchName",
},
}
for _, tc := range tests {
tc := tc

View file

@ -1 +1 @@
#[fg=default]#[fg=default]#[fg=white,bold]⎇ #[fg=default]master..#[fg=default]#[fg=cyan]origin/master#[fg=default] ↑·1 - #[fg=default]#[fg=green,bold]● 1 #[fg=red,bold]✚ 1 #[fg=cyan,bold]⚑ 1 #[fg=magenta,bold]… 1
#[fg=default]#[fg=default]#[fg=white,bold]⎇ #[fg=default]#[fg=white,bold]master..#[fg=default]#[fg=cyan]origin/master#[fg=default] ↑·1 - #[fg=default]#[fg=green,bold]● 1 #[fg=red,bold]✚ 1 #[fg=cyan,bold]⚑ 1 #[fg=magenta,bold]… 1