fix(git): use exact executable name

can conflict with git.cmd

relates to #315
This commit is contained in:
Jan De Dobbeleer 2021-03-07 17:05:10 +01:00 committed by Jan De Dobbeleer
parent f96f7ecc42
commit 21f97eebd2
2 changed files with 7 additions and 2 deletions

View file

@ -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

View file

@ -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",