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:
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user