mirror of
https://github.com/sobolevn/git-secret
synced 2024-11-02 21:40:18 +00:00
Modified ignore check, fixes #105.
This commit is contained in:
parent
4e6675363c
commit
b6852910dd
@ -266,7 +266,14 @@ function _check_ignore {
|
||||
local filename="$1" # required
|
||||
|
||||
local result
|
||||
result="$(git check-ignore --no-index -q "$filename" > /dev/null 2>&1; echo $?)"
|
||||
result="$(git add -n "$filename" > /dev/null 2>&1; echo $?)"
|
||||
# when ignored
|
||||
if [[ "$result" -ne 0 ]]; then
|
||||
result=0
|
||||
else
|
||||
result=1
|
||||
fi
|
||||
# returns 1 when not ignored, and 0 when ignored
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
@ -459,8 +466,17 @@ function _secrets_dir_is_not_ignored {
|
||||
local git_secret_dir
|
||||
git_secret_dir=$(_get_secrets_dir)
|
||||
|
||||
# Create git_secret_dir required for check
|
||||
local cleanup=0
|
||||
if [[ ! -d "$git_secret_dir" ]]; then
|
||||
mkdir "$git_secret_dir"
|
||||
cleanup=1
|
||||
fi
|
||||
local ignores
|
||||
ignores=$(_check_ignore "${_SECRETS_DIR}")
|
||||
ignores=$(_check_ignore "$git_secret_dir")
|
||||
if [[ "$cleanup" == 1 ]]; then
|
||||
rmdir "$git_secret_dir"
|
||||
fi
|
||||
|
||||
if [[ ! $ignores -eq 1 ]]; then
|
||||
_abort "'$git_secret_dir' is ignored."
|
||||
|
Loading…
Reference in New Issue
Block a user