11#! /usr/bin/env bash
22set -euo pipefail
33
4- scan_type=${1-pre-commit}
4+ scan_type=" ${1-pre-commit} "
55
66if ! git secrets -- 1> /dev/null; then
77 echo " git secrets is not installed"
@@ -19,20 +19,20 @@ if [[ -e ./.gitdisallowed ]]; then
1919 git secrets --add --allowed ' ^\.gitdisallowed:[0-9]+:.*' || true
2020fi
2121
22- if { [ " ${scan_type} " == " unstaged" ]; } ; then
22+ if { [[ " ${scan_type} " == " unstaged" ] ]; } ; then
2323 echo " scanning staged and unstaged files for secrets"
2424 git secrets --scan --recursive
2525 git secrets --scan --untracked
26- elif { [ " ${scan_type} " == " staged" ]; } ; then
26+ elif { [[ " ${scan_type} " == " staged" ] ]; } ; then
2727 echo " scanning staged files for secrets"
2828 git secrets --scan --recursive
29- elif { [ " ${scan_type} " == " commit-msg" ]; } ; then
29+ elif { [[ " ${scan_type} " == " commit-msg" ] ]; } ; then
3030 echo " checking commit msg for secrets"
3131 git secrets --commit_msg_hook -- " ${2} "
32- elif { [ " ${scan_type} " == " prep-commit-msg" ]; } ; then
32+ elif { [[ " ${scan_type} " == " prep-commit-msg" ] ]; } ; then
3333 echo " checking commit msg for secrets"
3434 git secrets --prepare_commit_msg_hook -- " ${2} "
35- elif { [ " ${scan_type} " == " history" ]; } ; then
35+ elif { [[ " ${scan_type} " == " history" ] ]; } ; then
3636 echo " checking commit history for secrets"
3737 git secrets --scan-history
3838else
0 commit comments