diff --git a/.github/hooks/pre-commit b/.github/hooks/pre-commit index e105b42..5f4231d 100644 --- a/.github/hooks/pre-commit +++ b/.github/hooks/pre-commit @@ -1,15 +1,14 @@ -#!/usr/bin/env sh - +#!/bin/sh # GITLEAKS_PRECOMMIT_HOOK BEGIN -precommit_version="v0.0.3" +precommit_latest_url=$(curl --silent --location --head --output /dev/null --write-out '%{url_effective}' -- https://github.com/GSA/odp-code-repository-commit-rules/releases/latest) +precommit_version=${precommit_latest_url##*/} precommit_url="https://raw.githubusercontent.com/GSA/odp-code-repository-commit-rules/${precommit_version}/gitleaks/precommit.sh" precommit_path="$(git rev-parse --show-toplevel)/.git/hooks/precommit.sh" -if [ ! -f "${precommit_path}" ]; then - curl --silent -o "${precommit_path}" "${precommit_url}" - if [ "$os" = "Linux" ] || [ "$os" = "Darwin" ]; then - chmod +x "${precommit_path}" - fi +curl --silent -o "${precommit_path}" "${precommit_url}" +os=$(uname -s | cut -d'_' -f 1) +if [ "$os" = "Linux" ] || [ "$os" = "Darwin" ]; then + chmod +x "${precommit_path}" fi "${precommit_path}" "${precommit_version}"