From ba072adcb99a5c77df2a93afccdca59a23703696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 23 Dec 2015 15:21:24 +0100 Subject: [PATCH] Have `rbenv local` read version from parent directories as well Fixes #807 --- libexec/rbenv-local | 9 +++++---- test/local.bats | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libexec/rbenv-local b/libexec/rbenv-local index 9169943e..d5c5f11c 100755 --- a/libexec/rbenv-local +++ b/libexec/rbenv-local @@ -47,9 +47,10 @@ elif [ -n "$RBENV_VERSION" ]; then } >&2 fi else - rbenv-version-file-read .ruby-version || - rbenv-version-file-read .rbenv-version || - { echo "rbenv: no local version configured for this directory" + if version_file="$(rbenv-version-file "$PWD")"; then + rbenv-version-file-read "$version_file" + else + echo "rbenv: no local version configured for this directory" >&2 exit 1 - } >&2 + fi fi diff --git a/test/local.bats b/test/local.bats index 3e93ca7f..a84833eb 100644 --- a/test/local.bats +++ b/test/local.bats @@ -32,11 +32,11 @@ setup() { assert_success "2.0" } -@test "ignores version in parent directory" { +@test "discovers version file in parent directory" { echo "1.2.3" > .ruby-version mkdir -p "subdir" && cd "subdir" run rbenv-local - assert_failure + assert_success "1.2.3" } @test "ignores RBENV_DIR" {