diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index d313836..991ff5b 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,5 +1,5 @@ - id: git-secrets name: Git Secrets description: git-secrets scans commits, commit messages, and --no-ff merges to prevent adding secrets into your git repositories. - entry: 'git-secrets --pre_commit_hook' + entry: pre-commit-hook-exec.sh language: script diff --git a/pre-commit-hook-exec.sh b/pre-commit-hook-exec.sh new file mode 100755 index 0000000..89ed79a --- /dev/null +++ b/pre-commit-hook-exec.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# pre-commit clones the git repo to a cache-directory that it manages. +# The entry script is executed using the absolute path to this cache-directory +# so we can use this to locate the git-secrets script and add it to PATH +# without requiring the user to manually install it. + +set -eu + +PARENTDIR=$(dirname "${BASH_SOURCE}") +export PATH="$PARENTDIR:$PATH" +exec git secrets --pre_commit_hook "$@"