From 368e04f3fa7629615247dd94380afafae5a69f57 Mon Sep 17 00:00:00 2001 From: native-api Date: Thu, 2 Feb 2023 15:15:16 +0300 Subject: [PATCH] Fix pyenv-latest to ignore virtualenvs (#2608) * Add test, exclude alphas as well --- libexec/pyenv-latest | 3 ++- test/latest.bats | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/libexec/pyenv-latest b/libexec/pyenv-latest index 8bc1b3f5..5c247105 100755 --- a/libexec/pyenv-latest +++ b/libexec/pyenv-latest @@ -48,9 +48,10 @@ IFS=$'\n' $(printf '%s\n' "${DEFINITION_CANDIDATES[@]}" | \ grep -Ee "^$prefix_re[-.]" || true)) + #FIXME: /envs/ should be excluded in Pyenv-Virtualenv via a hook DEFINITION_CANDIDATES=(\ $(printf '%s\n' "${DEFINITION_CANDIDATES[@]}" | \ - sed -E -e '/-dev$/d' -e '/-src$/d' -e '/-latest$/d' -e '/(b|rc)[0-9]+$/d')); + sed -E -e '/-dev$/d' -e '/-src$/d' -e '/-latest$/d' -e '/(a|b|rc)[0-9]+$/d' -e '/\/envs\//d')); # Compose a sorting key, followed by | and original value DEFINITION_CANDIDATES=(\ diff --git a/test/latest.bats b/test/latest.bats index 31474786..c145eff7 100644 --- a/test/latest.bats +++ b/test/latest.bats @@ -93,3 +93,22 @@ echo 3.10.6 3.10.8 ! } + +@test "ignores rolling releases, branch tips, alternative srcs, prereleases and virtualenvs" { + create_executable pyenv-versions <