Skip to content

Commit

Permalink
Talisman hook script ignore talisman upgrade based on variable (thoug…
Browse files Browse the repository at this point in the history
…htworks#211)

* set TALISMAN_UPGRADE_TIMEOUT for upgrade timeout(seconds). Default = 10 secs
* set TALISMAN_SKIP_UPGRADE to true to skip upgrade
  • Loading branch information
tinamthomas committed Aug 6, 2020
1 parent b94762f commit 0351c41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 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_TIMEOUT: Max 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
5 changes: 3 additions & 2 deletions global_install_scripts/talisman_hook_script.bash
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ talisman_hook_script)
esac

function check_and_upgrade_talisman_binary() {
if [ -n "${TALISMAN_HOME:-}" ]; then
LATEST_VERSION=$(curl -Is https://github.com/${ORG_REPO}/releases/latest | grep -E "Location" | grep -o '[^/]\+$' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
TALISMAN_UPGRADE_TIMEOUT=${TALISMAN_UPGRADE_TIMEOUT:-10}
if [[ -n "${TALISMAN_HOME:-}" && "$TALISMAN_SKIP_UPGRADE" != "true" ]]; then
LATEST_VERSION=$(curl -Is --max-time $TALISMAN_UPGRADE_TIMEOUT https://github.com/${ORG_REPO}/releases/latest | grep -E "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
echo ""
Expand Down

0 comments on commit 0351c41

Please sign in to comment.