diff --git a/git-secrets b/git-secrets index 8df3809..e849049 100755 --- a/git-secrets +++ b/git-secrets @@ -48,7 +48,7 @@ prepare_commit_msg_hook* prepare-commit-msg hook (internal only)" load_patterns() { git config --get-all secrets.patterns # Execute each provider and use their output to build up patterns - git config --get-all secrets.providers | while read -r cmd; do + git config --get-all --type path secrets.providers | while read -r cmd; do # Only split words on '\n\t ' and strip "\r" from the output to account # for carriage returns being added on Windows systems. Note that this # trimming is done before the test to ensure that the string is not empty. @@ -339,9 +339,17 @@ case "${COMMAND}" in --scan-history) scan_with_fn_or_die "scan_history" "$@" ;; --list) if [ ${GLOBAL} -eq 1 ]; then - git config --global --get-regex secrets.* + RESULT=1 + git config --global --get-regex --type path "^secrets\.providers$" && RESULT=0 + git config --global --get-regex "^secrets\.patterns$" && RESULT=0 + git config --global --get-regex "^secrets\.allowed$" && RESULT=0 + [ $RESULT -eq 0 ] else - git config --get-regex secrets.* + RESULT=1 + git config --get-regex --type path "^secrets\.providers$" && RESULT=0 + git config --get-regex "^secrets\.patterns$" && RESULT=0 + git config --get-regex "^secrets\.allowed$" && RESULT=0 + [ $RESULT -eq 0 ] fi ;; --install) diff --git a/test/git-secrets.bats b/test/git-secrets.bats index b7a5b1c..9edb7b5 100644 --- a/test/git-secrets.bats +++ b/test/git-secrets.bats @@ -311,6 +311,14 @@ load test_helper [ $status -eq 0 ] } +@test "Expands ~ in providers" { + repo_run git-secrets --add-provider -- '~/test' + [ $status -eq 0 ] + repo_run git-secrets --list + [ $status -eq 0 ] + echo "$output" | grep -F "${HOME}/test" +} + @test "--recursive cannot be used with SCAN_*" { repo_run git-secrets --scan -r --cached [ $status -eq 1 ]