diff --git a/README.md b/README.md index e7f8f102..6df15a58 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,11 @@ a real git revision!) # Upgrading Since release v0.4.4, Talisman automatically updates the binary to the latest release, when the hook is invoked (at pre-commit/pre-push, as set up). So, just sit back, relax, and keep using the latest Talisman without any extra efforts. +The following environment variables can be set: + +1. TALISMAN_SKIP_UPGRADE: Set to true if you want to skip the automatic upgrade check. Default is false +2. TALISMAN_UPGRADE_CONNECT_TIMEOUT: Max connect timeout before the upgrade is cancelled(in seconds). Default is 10 seconds. + If at all you need to manually upgrade, here are the steps:
[Recommended] Update Talisman binary and hook scripts to the latest release: diff --git a/global_install_scripts/talisman_hook_script.bash b/global_install_scripts/talisman_hook_script.bash index 5c6ddc80..22400899 100755 --- a/global_install_scripts/talisman_hook_script.bash +++ b/global_install_scripts/talisman_hook_script.bash @@ -45,14 +45,19 @@ talisman_hook_script) ;; esac +TALISMAN_UPGRADE_CONNECT_TIMEOUT=${TALISMAN_UPGRADE_CONNECT_TIMEOUT:-10} function check_and_upgrade_talisman_binary() { - if [ -n "${TALISMAN_HOME:-}" ]; then - LATEST_VERSION=$(curl -Is https://github.com/${ORG_REPO}/releases/latest | grep -iE "^location:" | grep -o '[^/]\+$' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+') + if [[ -n "${TALISMAN_HOME:-}" && "$TALISMAN_SKIP_UPGRADE" != "true" ]]; then + LATEST_VERSION=$(curl --connect-timeout $TALISMAN_UPGRADE_CONNECT_TIMEOUT -Is https://github.com/${ORG_REPO}/releases/latest | grep -iE "^location:" | grep -o '[^/]\+$' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+') CURRENT_VERSION=$(${TALISMAN_BINARY} --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+') - if [ ! -z "$LATEST_VERSION" ] && [ "$LATEST_VERSION" != "$CURRENT_VERSION" ]; then + if [ -z "$LATEST_VERSION" ]; then + echo_warning "Failed to retrieve latest version, skipping update." + elif [ "$LATEST_VERSION" != "$CURRENT_VERSION" ]; then echo "" echo_warning "Your version of Talisman is outdated. Updating Talisman to v${LATEST_VERSION}" curl --silent https://raw.githubusercontent.com/${ORG_REPO}/master/global_install_scripts/update_talisman.bash >/tmp/update_talisman.bash && /bin/bash /tmp/update_talisman.bash talisman-binary + else + echo_debug "Talisman version up-to-date, skipping update" fi fi }