mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 13:04:04 -08:00
fix(python): do not validate empty env
This commit is contained in:
parent
6c45afa89a
commit
266fc5671f
|
@ -70,6 +70,9 @@ func (p *Python) loadContext() {
|
||||||
var venv string
|
var venv string
|
||||||
for _, venvVar := range venvVars {
|
for _, venvVar := range venvVars {
|
||||||
venv = p.language.env.Getenv(venvVar)
|
venv = p.language.env.Getenv(venvVar)
|
||||||
|
if len(venv) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
name := environment.Base(p.language.env, venv)
|
name := environment.Base(p.language.env, venv)
|
||||||
if p.canUseVenvName(name) {
|
if p.canUseVenvName(name) {
|
||||||
p.Venv = name
|
p.Venv = name
|
||||||
|
@ -83,9 +86,6 @@ func (p *Python) inContext() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Python) canUseVenvName(name string) bool {
|
func (p *Python) canUseVenvName(name string) bool {
|
||||||
if name == "" || name == "." {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if p.language.props.GetBool(properties.DisplayDefault, true) {
|
if p.language.props.GetBool(properties.DisplayDefault, true) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ func TestPythonPythonInContext(t *testing.T) {
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
env := new(mock.MockedEnvironment)
|
env := new(mock.MockedEnvironment)
|
||||||
env.On("GOOS").Return("")
|
env.On("GOOS").Return("")
|
||||||
env.On("PathSeparator").Return("")
|
env.On("PathSeparator").Return("/")
|
||||||
env.On("Getenv", "VIRTUAL_ENV").Return(tc.VirtualEnvName)
|
env.On("Getenv", "VIRTUAL_ENV").Return(tc.VirtualEnvName)
|
||||||
env.On("Getenv", "CONDA_ENV_PATH").Return("")
|
env.On("Getenv", "CONDA_ENV_PATH").Return("")
|
||||||
env.On("Getenv", "CONDA_DEFAULT_ENV").Return("")
|
env.On("Getenv", "CONDA_DEFAULT_ENV").Return("")
|
||||||
|
|
Loading…
Reference in a new issue