fix(git): move untracked to added

resolves #628
This commit is contained in:
Jan De Dobbeleer 2021-04-12 19:28:32 +02:00 committed by Jan De Dobbeleer
parent 3f046e31a1
commit 434cd41faf
2 changed files with 8 additions and 12 deletions

View file

@ -23,7 +23,6 @@ type gitStatus struct {
deleted int
added int
modified int
untracked int
changed bool
}
@ -38,7 +37,6 @@ func (s *gitStatus) string() string {
status += stringIfValue(s.added, "+")
status += stringIfValue(s.modified, "~")
status += stringIfValue(s.deleted, "-")
status += stringIfValue(s.untracked, "?")
status += stringIfValue(s.unmerged, "x")
return status
}
@ -384,7 +382,7 @@ func (g *git) parseGitStats(output []string, working bool) *gitStatus {
switch code {
case "?":
if working {
status.untracked++
status.added++
}
case "D":
status.deleted++
@ -396,7 +394,7 @@ func (g *git) parseGitStats(output []string, working bool) *gitStatus {
status.modified++
}
}
status.changed = status.added > 0 || status.deleted > 0 || status.modified > 0 || status.unmerged > 0 || status.untracked > 0
status.changed = status.added > 0 || status.deleted > 0 || status.modified > 0 || status.unmerged > 0
return &status
}

View file

@ -352,9 +352,8 @@ func TestParseGitStatsWorking(t *testing.T) {
status := g.parseGitStats(output, true)
assert.Equal(t, 3, status.modified)
assert.Equal(t, 1, status.unmerged)
assert.Equal(t, 1, status.added)
assert.Equal(t, 3, status.added)
assert.Equal(t, 1, status.deleted)
assert.Equal(t, 2, status.untracked)
assert.True(t, status.changed)
}
@ -376,7 +375,6 @@ func TestParseGitStatsStaging(t *testing.T) {
assert.Equal(t, 0, status.unmerged)
assert.Equal(t, 1, status.added)
assert.Equal(t, 2, status.deleted)
assert.Equal(t, 0, status.untracked)
assert.True(t, status.changed)
}