From 79bfc9d3623632073c1ce320b3e70613a2584a68 Mon Sep 17 00:00:00 2001 From: Beau Barker Date: Wed, 17 Sep 2014 19:50:41 +1000 Subject: [PATCH 1/3] When changing from a virtualenv to "system", unset PYENV_DEACTIVATE. Previously the var remained set, which made it impossible to reactivate the previous virtualenv --- bin/pyenv-virtualenv-init | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/pyenv-virtualenv-init b/bin/pyenv-virtualenv-init index 62a221e..1ec7f20 100755 --- a/bin/pyenv-virtualenv-init +++ b/bin/pyenv-virtualenv-init @@ -112,6 +112,7 @@ if [[ "$shell" != "fish" ]]; then if [ -n "\$PYENV_ACTIVATE" ]; then if [ "\$(pyenv version-name)" = "system" ]; then pyenv deactivate --no-error --verbose + unset PYENV_DEACTIVATE return 0 fi if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix)" ]; then From d6671249b72fb442266ae2eeb33a479dd4d07f1e Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Sun, 12 Oct 2014 21:34:18 +0900 Subject: [PATCH 2/3] Should not persist `PYENV_DEACTIVATE` after automatic deactivation (#47, #48) --- bin/pyenv-virtualenv-init | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/pyenv-virtualenv-init b/bin/pyenv-virtualenv-init index 1ec7f20..66562a1 100755 --- a/bin/pyenv-virtualenv-init +++ b/bin/pyenv-virtualenv-init @@ -78,10 +78,12 @@ function _pyenv_virtualenv_hook --on-event fish_prompt; if [ -n "\$PYENV_ACTIVATE" ] if [ (pyenv version-name) = "system" ] pyenv deactivate --no-error --verbose + set -e PYENV_DEACTIVATE return 0 end if [ "\$PYENV_ACTIVATE" != (pyenv prefix) ] if pyenv deactivate --no-error --verbose + set -e PYENV_DEACTIVATE pyenv activate --no-error --verbose; or set -e PYENV_DEACTIVATE else pyenv activate --no-error --verbose @@ -117,6 +119,7 @@ if [[ "$shell" != "fish" ]]; then fi if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix)" ]; then if pyenv deactivate --no-error --verbose; then + unset PYENV_DEACTIVATE pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE else pyenv activate --no-error --verbose From e655abbd416ec6223fc05a9e4a46eb5f3029a640 Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Sun, 12 Oct 2014 21:37:10 +0900 Subject: [PATCH 3/3] Fix broken tests (#47) --- test/init.bats | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/init.bats b/test/init.bats index 65dfbda..7712c9e 100644 --- a/test/init.bats +++ b/test/init.bats @@ -34,10 +34,12 @@ _pyenv_virtualenv_hook() { if [ -n "\$PYENV_ACTIVATE" ]; then if [ "\$(pyenv version-name)" = "system" ]; then pyenv deactivate --no-error --verbose + unset PYENV_DEACTIVATE return 0 fi if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix)" ]; then if pyenv deactivate --no-error --verbose; then + unset PYENV_DEACTIVATE pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE else pyenv activate --no-error --verbose @@ -64,10 +66,12 @@ function _pyenv_virtualenv_hook --on-event fish_prompt; if [ -n "\$PYENV_ACTIVATE" ] if [ (pyenv version-name) = "system" ] pyenv deactivate --no-error --verbose + set -e PYENV_DEACTIVATE return 0 end if [ "\$PYENV_ACTIVATE" != (pyenv prefix) ] if pyenv deactivate --no-error --verbose + set -e PYENV_DEACTIVATE pyenv activate --no-error --verbose; or set -e PYENV_DEACTIVATE else pyenv activate --no-error --verbose @@ -91,10 +95,12 @@ _pyenv_virtualenv_hook() { if [ -n "\$PYENV_ACTIVATE" ]; then if [ "\$(pyenv version-name)" = "system" ]; then pyenv deactivate --no-error --verbose + unset PYENV_DEACTIVATE return 0 fi if [ "\$PYENV_ACTIVATE" != "\$(pyenv prefix)" ]; then if pyenv deactivate --no-error --verbose; then + unset PYENV_DEACTIVATE pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE else pyenv activate --no-error --verbose