mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-15 23:03:53 -05:00
Improve rbenv --version git checkout discovery
When `rbenv --version` is called, this now happens: 1. It changes into the directory where `libexec/rbenv--version` resides and checks if it's a checkout of the rbenv repo (as opposed to Homebrew checkout or something else). Then it reads the git revision. 2. If that failed, change to `$RBENV_ROOT` directory and repeat step 1.
This commit is contained in:
@@ -13,10 +13,14 @@ set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
version="0.4.0"
|
||||
git_revision=""
|
||||
|
||||
if cd "$RBENV_ROOT" 2>/dev/null; then
|
||||
git_revision="$(git describe --tags HEAD 2>/dev/null || true)"
|
||||
git_revision="${git_revision#v}"
|
||||
fi
|
||||
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
|
||||
|
||||
echo "rbenv ${git_revision:-$version}"
|
||||
|
||||
Reference in New Issue
Block a user