mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -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 {
|
if len(g.BranchStatus) > 0 {
|
||||||
buffer.WriteString(g.BranchStatus)
|
buffer.WriteString(g.BranchStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// status
|
||||||
if g.Staging.Changed() {
|
if g.Staging.Changed() {
|
||||||
fmt.Fprint(buffer, g.getStatusDetailString(g.Staging, StagingColor, LocalStagingIcon, " \uF046"))
|
fmt.Fprint(buffer, g.getStatusDetailString(g.Staging, StagingColor, LocalStagingIcon, " \uF046"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,6 +242,8 @@ func TestStatusColorsWithoutDisplayStatus(t *testing.T) {
|
||||||
LocalChangesColor: expected,
|
LocalChangesColor: expected,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
g.Working = &GitStatus{}
|
||||||
|
g.Staging = &GitStatus{}
|
||||||
g.string()
|
g.string()
|
||||||
assert.Equal(t, expected, g.props[BackgroundOverride])
|
assert.Equal(t, expected, g.props[BackgroundOverride])
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,6 +183,9 @@ func (g *git) string() string {
|
||||||
g.setGitStatus()
|
g.setGitStatus()
|
||||||
g.setGitHEADContext()
|
g.setGitHEADContext()
|
||||||
g.BranchStatus = g.getBranchStatus()
|
g.BranchStatus = g.getBranchStatus()
|
||||||
|
} else {
|
||||||
|
g.Working = &GitStatus{}
|
||||||
|
g.Staging = &GitStatus{}
|
||||||
}
|
}
|
||||||
if g.Upstream != "" && g.props.getOneOfBool(FetchUpstreamIcon, DisplayUpstreamIcon, false) {
|
if g.Upstream != "" && g.props.getOneOfBool(FetchUpstreamIcon, DisplayUpstreamIcon, false) {
|
||||||
g.UpstreamIcon = g.getUpstreamIcon()
|
g.UpstreamIcon = g.getUpstreamIcon()
|
||||||
|
@ -274,8 +277,6 @@ func (g *git) setGitStatus() {
|
||||||
UPSTREAM = "# branch.upstream "
|
UPSTREAM = "# branch.upstream "
|
||||||
BRANCHSTATUS = "# branch.ab "
|
BRANCHSTATUS = "# branch.ab "
|
||||||
)
|
)
|
||||||
g.Staging = &GitStatus{}
|
|
||||||
g.Working = &GitStatus{}
|
|
||||||
output := g.getGitCommandOutput("status", "-unormal", "--branch", "--porcelain=2")
|
output := g.getGitCommandOutput("status", "-unormal", "--branch", "--porcelain=2")
|
||||||
for _, line := range strings.Split(output, "\n") {
|
for _, line := range strings.Split(output, "\n") {
|
||||||
if strings.HasPrefix(line, HASH) {
|
if strings.HasPrefix(line, HASH) {
|
||||||
|
|
|
@ -364,6 +364,8 @@ func TestSetGitStatus(t *testing.T) {
|
||||||
if tc.ExpectedStaging == nil {
|
if tc.ExpectedStaging == nil {
|
||||||
tc.ExpectedStaging = &GitStatus{}
|
tc.ExpectedStaging = &GitStatus{}
|
||||||
}
|
}
|
||||||
|
g.Working = &GitStatus{}
|
||||||
|
g.Staging = &GitStatus{}
|
||||||
g.setGitStatus()
|
g.setGitStatus()
|
||||||
assert.Equal(t, tc.ExpectedStaging, g.Staging, tc.Case)
|
assert.Equal(t, tc.ExpectedStaging, g.Staging, tc.Case)
|
||||||
assert.Equal(t, tc.ExpectedWorking, g.Working, tc.Case)
|
assert.Equal(t, tc.ExpectedWorking, g.Working, tc.Case)
|
||||||
|
|
Loading…
Reference in a new issue