fix(git): initialize status correctly

This commit is contained in:
Jan De Dobbeleer 2021-12-08 14:53:41 +01:00
parent f25ade45cf
commit d9e642a132
No known key found for this signature in database
GPG key ID: F6CC273CE5BA9AEE
2 changed files with 2 additions and 2 deletions

View file

@ -280,6 +280,8 @@ func (g *git) setGitStatus() {
UPSTREAM = "# branch.upstream "
BRANCHSTATUS = "# branch.ab "
)
g.Working = &GitStatus{}
g.Staging = &GitStatus{}
output := g.getGitCommandOutput("status", "-unormal", "--branch", "--porcelain=2")
for _, line := range strings.Split(output, "\n") {
if strings.HasPrefix(line, HASH) {

View file

@ -364,8 +364,6 @@ func TestSetGitStatus(t *testing.T) {
if tc.ExpectedStaging == nil {
tc.ExpectedStaging = &GitStatus{}
}
g.Working = &GitStatus{}
g.Staging = &GitStatus{}
g.setGitStatus()
assert.Equal(t, tc.ExpectedStaging, g.Staging, tc.Case)
assert.Equal(t, tc.ExpectedWorking, g.Working, tc.Case)