Fix pyenv-latest to ignore virtualenvs (#2608)

* Add test, exclude alphas as well
This commit is contained in:
native-api 2023-02-02 15:15:16 +03:00 committed by GitHub
parent 76e93b073e
commit 368e04f3fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -48,9 +48,10 @@ IFS=$'\n'
$(printf '%s\n' "${DEFINITION_CANDIDATES[@]}" | \ $(printf '%s\n' "${DEFINITION_CANDIDATES[@]}" | \
grep -Ee "^$prefix_re[-.]" || true)) grep -Ee "^$prefix_re[-.]" || true))
#FIXME: <version>/envs/<virtualenv> should be excluded in Pyenv-Virtualenv via a hook
DEFINITION_CANDIDATES=(\ DEFINITION_CANDIDATES=(\
$(printf '%s\n' "${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 # Compose a sorting key, followed by | and original value
DEFINITION_CANDIDATES=(\ DEFINITION_CANDIDATES=(\

View file

@ -93,3 +93,22 @@ echo 3.10.6
3.10.8 3.10.8
! !
} }
@test "ignores rolling releases, branch tips, alternative srcs, prereleases and virtualenvs" {
create_executable pyenv-versions <<!
#!$BASH
echo 3.8.5-dev
echo 3.8.5-src
echo 3.8.5-latest
echo 3.8.5a2
echo 3.8.5b3
echo 3.8.5rc2
echo 3.8.1
echo 3.8.1/envs/foo
!
run pyenv-latest 3.8
assert_success
assert_output <<!
3.8.1
!
}