diff --git a/src/segment_git.go b/src/segment_git.go index 6f6bd8ca..199b1584 100644 --- a/src/segment_git.go +++ b/src/segment_git.go @@ -112,8 +112,6 @@ const ( BehindColor Property = "behind_color" // AheadColor if set, the color to use when the branch is ahead and behind the remote AheadColor Property = "ahead_color" - - gitCommand = "git" ) func (g *git) enabled() bool { @@ -272,6 +270,10 @@ func (g *git) getStatusColor(defaultValue string) string { } func (g *git) getGitCommandOutput(args ...string) string { + gitCommand := "git" + if g.env.getRuntimeGOOS() == "windows" { + gitCommand = "git.exe" + } args = append([]string{"--no-optional-locks", "-c", "core.quotepath=false", "-c", "color.status=false"}, args...) val, _ := g.env.runCommand(gitCommand, args...) return val diff --git a/src/segment_git_test.go b/src/segment_git_test.go index 16ebaa92..df713c89 100644 --- a/src/segment_git_test.go +++ b/src/segment_git_test.go @@ -59,6 +59,7 @@ func TestGetGitOutputForCommand(t *testing.T) { want := "je suis le output" env := new(MockedEnvironment) env.On("runCommand", "git", append(args, commandArgs...)).Return(want, nil) + env.On("getRuntimeGOOS", nil).Return("unix") g := &git{ env: env, } @@ -103,6 +104,7 @@ func setupHEADContextEnv(context *detachedContext) *git { env.mockGitCommand(context.tagName, "describe", "--tags", "--exact-match") env.mockGitCommand(context.origin, "name-rev", "--name-only", "--exclude=tags/*", context.origin) env.mockGitCommand(context.onto, "name-rev", "--name-only", "--exclude=tags/*", context.onto) + env.On("getRuntimeGOOS", nil).Return("unix") g := &git{ env: env, repo: &gitRepo{ @@ -401,6 +403,7 @@ func TestParseGitStatsInvalidLine(t *testing.T) { func bootstrapUpstreamTest(upstream string) *git { env := &MockedEnvironment{} env.On("runCommand", "git", []string{"--no-optional-locks", "-c", "core.quotepath=false", "-c", "color.status=false", "remote", "get-url", "origin"}).Return(upstream, nil) + env.On("getRuntimeGOOS", nil).Return("unix") props := &properties{ values: map[Property]interface{}{ GithubIcon: "GH",