fix(git): include al untracked files

relates to #1422
This commit is contained in:
Jan De Dobbeleer 2021-12-13 17:37:06 +01:00 committed by Jan De Dobbeleer
parent fb1ed7f695
commit 84e3bea1ea
2 changed files with 19 additions and 3 deletions

View file

@ -224,14 +224,14 @@ func (g *git) getUpstreamIcon() string {
func (g *git) setGitStatus() {
addToStatus := func(status string) {
if len(status) <= 4 {
return
}
const UNTRACKED = "?"
if strings.HasPrefix(status, UNTRACKED) {
g.Working.add(UNTRACKED)
return
}
if len(status) <= 4 {
return
}
workingCode := status[3:4]
stagingCode := status[2:3]
g.Working.add(workingCode)

View file

@ -361,6 +361,22 @@ func TestSetGitStatus(t *testing.T) {
ExpectedAhead: 2,
ExpectedBehind: 1,
},
{
Case: "untracked files",
Output: `
# branch.oid 1234567891011121314
# branch.head main
# branch.upstream origin/main
# branch.ab +0 -0
? q
? qq
? qqq
`,
ExpectedUpstream: "origin/main",
ExpectedHash: "1234567",
ExpectedRef: "main",
ExpectedWorking: &GitStatus{ScmStatus: ScmStatus{Added: 3}},
},
}
for _, tc := range cases {
env := new(MockedEnvironment)