1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-16 15:23:53 -05:00

Improve git --version git revision lookup

It doesn't try to chdir into RBENV_ROOT anymore because that might be
a location of an unrelated rbenv install that might have a different
version than the current one that is installed e.g. via a package
manager such as Homebrew.

Now just tries the repo where the source files (`libexec/*`) are
located, and if that isn't a valid rbenv repo, bail out early.
This commit is contained in:
Mislav Marohnić
2015-12-24 03:52:33 +01:00
parent 6481cbb172
commit 1a0be6f0ad
2 changed files with 11 additions and 33 deletions

View File

@@ -15,12 +15,9 @@ set -e
version="0.4.0"
git_revision=""
for source_dir in "${BASH_SOURCE%/*}" "$RBENV_ROOT"; do
if cd "$source_dir" 2>/dev/null && git remote -v 2>/dev/null | grep -q rbenv; then
git_revision="$(git describe --tags HEAD 2>/dev/null || true)"
git_revision="${git_revision#v}"
[ -z "$git_revision" ] || break
fi
done
if cd "${BASH_SOURCE%/*}" 2>/dev/null && git remote -v 2>/dev/null | grep -q rbenv; then
git_revision="$(git describe --tags HEAD 2>/dev/null || true)"
git_revision="${git_revision#v}"
fi
echo "rbenv ${git_revision:-$version}"