Skip to content

Commit

Permalink
Merge 4916914 into a917db6
Browse files Browse the repository at this point in the history
  • Loading branch information
tinamthomas committed Aug 12, 2020
2 parents a917db6 + 4916914 commit e81c448
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ a real git revision!)
# Upgrading
Since release v0.4.4, Talisman <b>automatically updates</b> 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:
<br>[Recommended] Update Talisman binary and hook scripts to the latest release:

Expand Down
11 changes: 8 additions & 3 deletions global_install_scripts/talisman_hook_script.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e81c448

Please sign in to comment.