mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 04:54:03 -08:00
fix(git): initialize status correctly
This commit is contained in:
parent
4294351e6f
commit
04f841d1b3
|
@ -87,6 +87,8 @@ func (g *git) deprecatedString(statusColorsEnabled bool) string {
|
|||
if len(g.BranchStatus) > 0 {
|
||||
buffer.WriteString(g.BranchStatus)
|
||||
}
|
||||
|
||||
// status
|
||||
if g.Staging.Changed() {
|
||||
fmt.Fprint(buffer, g.getStatusDetailString(g.Staging, StagingColor, LocalStagingIcon, " \uF046"))
|
||||
}
|
||||
|
|
|
@ -242,6 +242,8 @@ func TestStatusColorsWithoutDisplayStatus(t *testing.T) {
|
|||
LocalChangesColor: expected,
|
||||
},
|
||||
}
|
||||
g.Working = &GitStatus{}
|
||||
g.Staging = &GitStatus{}
|
||||
g.string()
|
||||
assert.Equal(t, expected, g.props[BackgroundOverride])
|
||||
}
|
||||
|
|
|
@ -183,6 +183,9 @@ func (g *git) string() string {
|
|||
g.setGitStatus()
|
||||
g.setGitHEADContext()
|
||||
g.BranchStatus = g.getBranchStatus()
|
||||
} else {
|
||||
g.Working = &GitStatus{}
|
||||
g.Staging = &GitStatus{}
|
||||
}
|
||||
if g.Upstream != "" && g.props.getOneOfBool(FetchUpstreamIcon, DisplayUpstreamIcon, false) {
|
||||
g.UpstreamIcon = g.getUpstreamIcon()
|
||||
|
@ -274,8 +277,6 @@ func (g *git) setGitStatus() {
|
|||
UPSTREAM = "# branch.upstream "
|
||||
BRANCHSTATUS = "# branch.ab "
|
||||
)
|
||||
g.Staging = &GitStatus{}
|
||||
g.Working = &GitStatus{}
|
||||
output := g.getGitCommandOutput("status", "-unormal", "--branch", "--porcelain=2")
|
||||
for _, line := range strings.Split(output, "\n") {
|
||||
if strings.HasPrefix(line, HASH) {
|
||||
|
|
|
@ -364,6 +364,8 @@ 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)
|
||||
|
|
Loading…
Reference in a new issue