Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions git-secrets
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,19 @@ add_config() {
value=$(sed 's/[\.|$(){}?+*^]/\\&/g' <<< "${value}")
fi
if [ ${GLOBAL} -eq 1 ]; then
git config --global --get-all $key | grep -Fq "${value}" && return 1
git config --global --add "${key}" "${value}"
git config --global --get-all $key | grep -Fq -- "${value}"
case $? in
0) return 1 ;; # value already exists
2) return 1 ;; # grep error
*) git config --global --add "${key}" "${value}" ;;
esac
else
git config --get-all $key | grep -Fq "${value}" && return 1
git config --add "${key}" "${value}"
git config --get-all $key | grep -Fq -- "${value}"
case $? in
0) return 1 ;; # value already exists
2) return 1 ;; # grep error
*) git config --add "${key}" "${value}" ;;
esac
fi
}

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

@test "Adds secrets beginning with --" {
repo_run git-secrets --add --literal --global -- '--TEST'
[ $status -eq 0 ]
}

@test "Empty lines must be ignored in .gitallowed files" {
setup_bad_repo
echo '' >> $TEST_REPO/.gitallowed
Expand Down