Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we instead just do entry: './git-secrets --pre-commit-hook' (possibly even minus the quotes)?

I am not too familiar with pre-commit so I understand I might be missing some context here.

That said, your solution may also be preferable if your use of git secrets causes existing git configuration to be honored in a way that directly calling the git-secrets script does not.

language: script
11 changes: 11 additions & 0 deletions pre-commit-hook-exec.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"