From 49fba599e872bc761858ea6f700271fb6dcb5a97 Mon Sep 17 00:00:00 2001 From: Conner Crosby Date: Sat, 30 Apr 2022 22:04:07 -0400 Subject: [PATCH] Add an ability to install a specific version of pyenv (#126) --- README.rst | 2 ++ bin/pyenv-installer | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 65f8bc5..101edce 100644 --- a/README.rst +++ b/README.rst @@ -19,6 +19,8 @@ Once prerequisites have been installed correctly: Install: ~~~~ +If you wish to install a specific release of Pyenv rather than the latest head, set the ``PYENV_GIT_TAG`` environment variable (e.g. ``export PYENV_GIT_TAG=v2.2.5``). + .. code:: bash curl https://pyenv.run | bash diff --git a/bin/pyenv-installer b/bin/pyenv-installer index f8916b6..80386fa 100755 --- a/bin/pyenv-installer +++ b/bin/pyenv-installer @@ -29,7 +29,7 @@ failed_checkout() { } checkout() { - [ -d "$2" ] || git clone --depth 1 "$1" "$2" || failed_checkout "$1" + [ -d "$2" ] || git -c advice.detachedHead=0 clone --branch "$3" --depth 1 "$1" "$2" || failed_checkout "$1" } if ! command -v git 1>/dev/null 2>&1; then @@ -43,12 +43,12 @@ else GITHUB="https://github.com" fi -checkout "${GITHUB}/pyenv/pyenv.git" "${PYENV_ROOT}" -checkout "${GITHUB}/pyenv/pyenv-doctor.git" "${PYENV_ROOT}/plugins/pyenv-doctor" -checkout "${GITHUB}/pyenv/pyenv-installer.git" "${PYENV_ROOT}/plugins/pyenv-installer" -checkout "${GITHUB}/pyenv/pyenv-update.git" "${PYENV_ROOT}/plugins/pyenv-update" -checkout "${GITHUB}/pyenv/pyenv-virtualenv.git" "${PYENV_ROOT}/plugins/pyenv-virtualenv" -checkout "${GITHUB}/pyenv/pyenv-which-ext.git" "${PYENV_ROOT}/plugins/pyenv-which-ext" +checkout "${GITHUB}/pyenv/pyenv.git" "${PYENV_ROOT}" "${PYENV_GIT_TAG:-master}" +checkout "${GITHUB}/pyenv/pyenv-doctor.git" "${PYENV_ROOT}/plugins/pyenv-doctor" "master" +checkout "${GITHUB}/pyenv/pyenv-installer.git" "${PYENV_ROOT}/plugins/pyenv-installer" "master" +checkout "${GITHUB}/pyenv/pyenv-update.git" "${PYENV_ROOT}/plugins/pyenv-update" "master" +checkout "${GITHUB}/pyenv/pyenv-virtualenv.git" "${PYENV_ROOT}/plugins/pyenv-virtualenv" "master" +checkout "${GITHUB}/pyenv/pyenv-which-ext.git" "${PYENV_ROOT}/plugins/pyenv-which-ext" "master" if ! command -v pyenv 1>/dev/null; then { echo