Skip to content

Commit

Permalink
ignore empty and comment lines in gitallowed
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwittig committed May 4, 2016
1 parent 6e6c42f commit 45e3d87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions git-secrets
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ load_patterns() {
}

load_allowed() {
git config --get-all secrets.allowed
git config --get-all secrets.allowed | awk 'NF && $1!~/^#/'
local gitallowed="$(git rev-parse --show-toplevel)/.gitallowed"
if [ -e "$gitallowed" ]; then
cat $gitallowed
cat $gitallowed | awk 'NF && $1!~/^#/'
fi
}

Expand Down
7 changes: 7 additions & 0 deletions test/git-secrets.bats
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ load test_helper
echo "$output" | grep -F 'secrets.allowed testing\+abc'
}

@test "Empty lines must be ignored in .gitallowed files" {
setup_bad_repo
echo '' >> $TEST_REPO/.gitallowed
repo_run git-secrets --scan
[ $status -eq 1 ]
}

@test "Scans all files and allowing none of the bad patterns in .gitallowed" {
setup_bad_repo
echo 'hello' > $TEST_REPO/.gitallowed
Expand Down

0 comments on commit 45e3d87

Please sign in to comment.