浏览代码

Fix resolution of a name that's a prefix of another name (#2521)

pull/2527/head
native-api 1年前
提交者 GitHub
父节点
当前提交
ed1083ec27
找不到此签名对应的密钥 GPG 密钥 ID: 4AEE18F83AFDEB23
共有 2 个文件被更改,包括 21 次插入0 次删除
  1. +6
    -0
      libexec/pyenv-latest
  2. +15
    -0
      test/latest.bats

+ 6
- 0
libexec/pyenv-latest 查看文件

@ -35,6 +35,12 @@ IFS=$'\n'
else
DEFINITION_CANDIDATES=( $(python-build --definitions ) )
fi
if printf '%s\n' "${DEFINITION_CANDIDATES[@]}" | grep -qxFe "$prefix"; then
echo "$prefix"
exit $exitcode;
fi
# https://stackoverflow.com/questions/11856054/is-there-an-easy-way-to-pass-a-raw-string-to-grep/63483807#63483807
prefix_re="$(sed 's/[^\^]/[&]/g;s/[\^]/\\&/g' <<< "$prefix")"
# FIXME: more reliable and readable would probably be to loop over them and transform in pure Bash

+ 15
- 0
test/latest.bats 查看文件

@ -64,6 +64,21 @@ pyenv: no known versions match the prefix \`3.8'
!
}
@test "complete name resolves to itself" {
create_executable pyenv-versions <<!
#!$BASH
echo foo
echo foo.bar
!
run pyenv-latest foo
assert_success
assert_output <<!
foo
!
}
@test "sort CPython" {
create_executable pyenv-versions <<!
#!$BASH

正在加载...
取消
保存