fix(git): add untracked

resolves #2349
This commit is contained in:
Jan De Dobbeleer 2022-05-30 08:51:39 +02:00 committed by Jan De Dobbeleer
parent a9c1292d83
commit 8bcbe02510
3 changed files with 8 additions and 4 deletions

View file

@ -21,8 +21,10 @@ func (s *GitStatus) add(code string) {
return
case "D":
s.Deleted++
case "A", "?":
case "A":
s.Added++
case "?":
s.Untracked++
case "U":
s.Unmerged++
case "M", "R", "C", "m":

View file

@ -368,7 +368,7 @@ func TestSetGitStatus(t *testing.T) {
1 .C N...
1 .M N...
1 .m N...
1 .? N...
1 .A N...
1 .D N...
1 .A N...
1 .U N...
@ -391,7 +391,7 @@ func TestSetGitStatus(t *testing.T) {
1 .C N...
1 .M N...
1 .m N...
1 .? N...
1 .A N...
1 .D N...
1 .A N...
1 .U N...
@ -443,7 +443,7 @@ func TestSetGitStatus(t *testing.T) {
ExpectedUpstream: "origin/main",
ExpectedHash: "1234567",
ExpectedRef: "main",
ExpectedWorking: &GitStatus{ScmStatus: ScmStatus{Added: 3}},
ExpectedWorking: &GitStatus{ScmStatus: ScmStatus{Untracked: 3}},
},
{
Case: "remote branch was deleted",

View file

@ -15,6 +15,7 @@ type ScmStatus struct {
Modified int
Moved int
Conflicted int
Untracked int
}
func (s *ScmStatus) Changed() bool {
@ -29,6 +30,7 @@ func (s *ScmStatus) String() string {
}
return ""
}
status += stringIfValue(s.Untracked, "?")
status += stringIfValue(s.Added, "+")
status += stringIfValue(s.Modified, "~")
status += stringIfValue(s.Deleted, "-")