1
0
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:
Mislav Marohnić
2015-10-25 16:54:38 +01:00
parent 0f44c57d08
commit dcca61c0bc
2 changed files with 36 additions and 4 deletions

View File

@@ -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}"