Introduce GH_PATH environment variable (#7025)
This commit is contained in:
parent
4636931b02
commit
05bf29d88e
3 changed files with 16 additions and 0 deletions
|
|
@ -83,6 +83,9 @@ var HelpTopics = map[string]map[string]string{
|
||||||
"$XDG_CONFIG_HOME/gh" or "$HOME/.config/gh".
|
"$XDG_CONFIG_HOME/gh" or "$HOME/.config/gh".
|
||||||
|
|
||||||
GH_PROMPT_DISABLED: set to any value to disable interactive prompting in the terminal.
|
GH_PROMPT_DISABLED: set to any value to disable interactive prompting in the terminal.
|
||||||
|
|
||||||
|
GH_PATH: set the path to the gh executable, useful for when gh can not properly determine
|
||||||
|
its own path such as in the cygwin terminal.
|
||||||
`),
|
`),
|
||||||
},
|
},
|
||||||
"reference": {
|
"reference": {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,10 @@ type Factory struct {
|
||||||
|
|
||||||
// Executable is the path to the currently invoked binary
|
// Executable is the path to the currently invoked binary
|
||||||
func (f *Factory) Executable() string {
|
func (f *Factory) Executable() string {
|
||||||
|
ghPath := os.Getenv("GH_PATH")
|
||||||
|
if ghPath != "" {
|
||||||
|
return ghPath
|
||||||
|
}
|
||||||
if !strings.ContainsRune(f.ExecutableName, os.PathSeparator) {
|
if !strings.ContainsRune(f.ExecutableName, os.PathSeparator) {
|
||||||
f.ExecutableName = executable(f.ExecutableName)
|
f.ExecutableName = executable(f.ExecutableName)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,3 +54,12 @@ func Test_executable(t *testing.T) {
|
||||||
t.Errorf("executable() = %q, want %q", got, bin2Exe)
|
t.Errorf("executable() = %q, want %q", got, bin2Exe)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Executable_override(t *testing.T) {
|
||||||
|
override := strings.Join([]string{"C:", "cygwin64", "home", "gh.exe"}, string(os.PathSeparator))
|
||||||
|
t.Setenv("GH_PATH", override)
|
||||||
|
f := Factory{}
|
||||||
|
if got := f.Executable(); got != override {
|
||||||
|
t.Errorf("executable() = %q, want %q", got, override)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue