4
0

pre-commit.example 520 B

12345678910111213141516171819
  1. #!/bin/sh
  2. # This is an example of what adding gitleaks to a pre-commit hook would look like.
  3. gitleaksEnabled=$(git config --bool hooks.gitleaks)
  4. cmd="/Users/zrice/go/src/github.com/zricethezav/gitleaks/gitleaks --verbose --redact --pretty"
  5. if [ $gitleaksEnabled == "true" ]; then
  6. $cmd
  7. if [ $? -eq 1 ]; then
  8. cat <<\EOF
  9. Error: gitleaks has detected sensitive information in your changes.
  10. If you know what you are doing you can disable this check using:
  11. git config hooks.gitleaks false
  12. EOF
  13. exit 1
  14. fi
  15. fi