mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 04:19:41 -08:00
fix(git): use exact executable name
can conflict with git.cmd relates to #315
This commit is contained in:
parent
f96f7ecc42
commit
21f97eebd2
|
@ -112,8 +112,6 @@ const (
|
||||||
BehindColor Property = "behind_color"
|
BehindColor Property = "behind_color"
|
||||||
// AheadColor if set, the color to use when the branch is ahead and behind the remote
|
// AheadColor if set, the color to use when the branch is ahead and behind the remote
|
||||||
AheadColor Property = "ahead_color"
|
AheadColor Property = "ahead_color"
|
||||||
|
|
||||||
gitCommand = "git"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *git) enabled() bool {
|
func (g *git) enabled() bool {
|
||||||
|
@ -272,6 +270,10 @@ func (g *git) getStatusColor(defaultValue string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *git) getGitCommandOutput(args ...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...)
|
args = append([]string{"--no-optional-locks", "-c", "core.quotepath=false", "-c", "color.status=false"}, args...)
|
||||||
val, _ := g.env.runCommand(gitCommand, args...)
|
val, _ := g.env.runCommand(gitCommand, args...)
|
||||||
return val
|
return val
|
||||||
|
|
|
@ -59,6 +59,7 @@ func TestGetGitOutputForCommand(t *testing.T) {
|
||||||
want := "je suis le output"
|
want := "je suis le output"
|
||||||
env := new(MockedEnvironment)
|
env := new(MockedEnvironment)
|
||||||
env.On("runCommand", "git", append(args, commandArgs...)).Return(want, nil)
|
env.On("runCommand", "git", append(args, commandArgs...)).Return(want, nil)
|
||||||
|
env.On("getRuntimeGOOS", nil).Return("unix")
|
||||||
g := &git{
|
g := &git{
|
||||||
env: env,
|
env: env,
|
||||||
}
|
}
|
||||||
|
@ -103,6 +104,7 @@ func setupHEADContextEnv(context *detachedContext) *git {
|
||||||
env.mockGitCommand(context.tagName, "describe", "--tags", "--exact-match")
|
env.mockGitCommand(context.tagName, "describe", "--tags", "--exact-match")
|
||||||
env.mockGitCommand(context.origin, "name-rev", "--name-only", "--exclude=tags/*", context.origin)
|
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.mockGitCommand(context.onto, "name-rev", "--name-only", "--exclude=tags/*", context.onto)
|
||||||
|
env.On("getRuntimeGOOS", nil).Return("unix")
|
||||||
g := &git{
|
g := &git{
|
||||||
env: env,
|
env: env,
|
||||||
repo: &gitRepo{
|
repo: &gitRepo{
|
||||||
|
@ -401,6 +403,7 @@ func TestParseGitStatsInvalidLine(t *testing.T) {
|
||||||
func bootstrapUpstreamTest(upstream string) *git {
|
func bootstrapUpstreamTest(upstream string) *git {
|
||||||
env := &MockedEnvironment{}
|
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("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{
|
props := &properties{
|
||||||
values: map[Property]interface{}{
|
values: map[Property]interface{}{
|
||||||
GithubIcon: "GH",
|
GithubIcon: "GH",
|
||||||
|
|
Loading…
Reference in a new issue