mirror of
https://github.com/pyenv/pyenv.git
synced 2024-12-22 10:13:35 +00:00
commit
6481cbb172
5 changed files with 49 additions and 1 deletions
|
@ -9,6 +9,8 @@ set -e
|
|||
if [ "$1" = "--complete" ]; then
|
||||
echo exec
|
||||
echo rehash
|
||||
echo version-name
|
||||
echo version-origin
|
||||
echo which
|
||||
exit
|
||||
fi
|
||||
|
|
|
@ -8,6 +8,13 @@ if [ -z "$RBENV_VERSION" ]; then
|
|||
RBENV_VERSION="$(rbenv-version-file-read "$RBENV_VERSION_FILE" || true)"
|
||||
fi
|
||||
|
||||
OLDIFS="$IFS"
|
||||
IFS=$'\n' scripts=(`rbenv-hooks version-name`)
|
||||
IFS="$OLDIFS"
|
||||
for script in "${scripts[@]}"; do
|
||||
source "$script"
|
||||
done
|
||||
|
||||
if [ -z "$RBENV_VERSION" ] || [ "$RBENV_VERSION" = "system" ]; then
|
||||
echo "system"
|
||||
exit
|
||||
|
|
|
@ -3,7 +3,18 @@
|
|||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
if [ -n "$RBENV_VERSION" ]; then
|
||||
unset RBENV_VERSION_ORIGIN
|
||||
|
||||
OLDIFS="$IFS"
|
||||
IFS=$'\n' scripts=(`rbenv-hooks version-origin`)
|
||||
IFS="$OLDIFS"
|
||||
for script in "${scripts[@]}"; do
|
||||
source "$script"
|
||||
done
|
||||
|
||||
if [ -n "$RBENV_VERSION_ORIGIN" ]; then
|
||||
echo "$RBENV_VERSION_ORIGIN"
|
||||
elif [ -n "$RBENV_VERSION" ]; then
|
||||
echo "RBENV_VERSION environment variable"
|
||||
else
|
||||
rbenv-version-file
|
||||
|
|
|
@ -22,6 +22,19 @@ setup() {
|
|||
assert_success "system"
|
||||
}
|
||||
|
||||
@test "RBENV_VERSION can be overridden by hook" {
|
||||
create_version "1.8.7"
|
||||
create_version "1.9.3"
|
||||
|
||||
mkdir -p "${RBENV_ROOT}/rbenv.d/version-name"
|
||||
cat > "${RBENV_ROOT}/rbenv.d/version-name/test.bash" <<HOOK
|
||||
RBENV_VERSION=1.9.3
|
||||
HOOK
|
||||
|
||||
RBENV_VERSION=1.8.7 RBENV_HOOK_PATH="${RBENV_ROOT}/rbenv.d" run rbenv-version-name
|
||||
assert_success "1.9.3"
|
||||
}
|
||||
|
||||
@test "RBENV_VERSION has precedence over local" {
|
||||
create_version "1.8.7"
|
||||
create_version "1.9.3"
|
||||
|
|
|
@ -36,3 +36,18 @@ setup() {
|
|||
run rbenv-version-origin
|
||||
assert_success "${PWD}/.rbenv-version"
|
||||
}
|
||||
|
||||
@test "reports from hook" {
|
||||
mkdir -p "${RBENV_ROOT}/rbenv.d/version-origin"
|
||||
cat > "${RBENV_ROOT}/rbenv.d/version-origin/test.bash" <<HOOK
|
||||
RBENV_VERSION_ORIGIN=plugin
|
||||
HOOK
|
||||
|
||||
RBENV_VERSION=1 RBENV_HOOK_PATH="${RBENV_ROOT}/rbenv.d" run rbenv-version-origin
|
||||
assert_success "plugin"
|
||||
}
|
||||
|
||||
@test "doesn't inherit RBENV_VERSION_ORIGIN from environment" {
|
||||
RBENV_VERSION_ORIGIN=ignored run rbenv-version-origin
|
||||
assert_success "${RBENV_ROOT}/version"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue