Skip to content

Commit

Permalink
fix(git): move untracked to added
Browse files Browse the repository at this point in the history
resolves #628
  • Loading branch information
JanDeDobbeleer committed Apr 12, 2021
1 parent 3f046e3 commit 434cd41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 7 additions & 9 deletions src/segment_git.go
Expand Up @@ -19,12 +19,11 @@ type gitRepo struct {
}

type gitStatus struct {
unmerged int
deleted int
added int
modified int
untracked int
changed bool
unmerged int
deleted int
added int
modified int
changed bool
}

func (s *gitStatus) string() string {
Expand All @@ -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
}
Expand Down Expand Up @@ -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++
Expand All @@ -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
}

Expand Down
4 changes: 1 addition & 3 deletions src/segment_git_test.go
Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down

0 comments on commit 434cd41

Please sign in to comment.