diff --git a/scripts/pre-commit.py b/scripts/pre-commit.py index 87c30bae..64d48d59 100644 --- a/scripts/pre-commit.py +++ b/scripts/pre-commit.py @@ -1,13 +1,18 @@ #!/usr/bin/env python3 -import os,sys +"""Helper script to be used as a pre-commit hook.""" +import os +import sys import subprocess + def gitleaksEnabled(): + """Determine if the pre-commit hook for gitleaks is enabled.""" out = subprocess.getoutput("git config --bool hooks.gitleaks") if out == "false": return False return True + if gitleaksEnabled(): exitCode = os.WEXITSTATUS(os.system('gitleaks protect -v --staged')) if exitCode == 1: @@ -18,5 +23,5 @@ To disable the gitleaks precommit hook run the following command: ''') sys.exit(1) else: - print('gitleaks precommit disabled (enable with `git config hooks.gitleaks true`)') - + print('gitleaks precommit disabled\ + (enable with `git config hooks.gitleaks true`)')