Merge pull request #90 from ctavan/fix-hide-delete-option-for-subdirectories

Make hide -d work with secrets in subdirectories
pull/42/merge
Sobolev Nikita 8 years ago committed by GitHub
commit 270c6dff6b

@ -282,7 +282,7 @@ function _find_and_clean {
root=$(_get_git_root_path)
# shellcheck disable=2086
find "$root" -name "$pattern" -type f -print0 | xargs -0 rm -f$verbose
find "$root" -path "$pattern" -type f -print0 | xargs -0 rm -f$verbose
}

@ -26,7 +26,7 @@ function _optional_delete {
while read -r line; do
# So the formating would not be repeated several times here:
_find_and_clean "$line" "$verbose"
_find_and_clean "*$line" "$verbose"
done < "$path_mappings"
if [[ ! -z "$verbose" ]]; then

@ -97,6 +97,32 @@ function teardown {
}
@test "run 'hide' with '-d' and '-v' and files in subdirectories" {
# Preparations:
local root_dir='test_sub_dir'
mkdir -p "$root_dir"
local second_file="$root_dir/second_file.txt"
local second_content="some content"
set_state_secret_add "$second_file" "$second_content"
# Verify that the second file is there:
[ -f "$second_file" ]
# Now it should hide 2 files:
run git secret hide -v -d
[ "$status" -eq 0 ]
# File must be removed:
[ ! -f "$FILE_TO_HIDE" ]
[ ! -f "$second_file" ]
# It should be verbose:
[[ "$output" == *"removing unencrypted files"* ]]
[[ "$output" == *"$FILE_TO_HIDE"* ]]
[[ "$output" == *"$second_file"* ]]
}
@test "run 'hide' with multiple users" {
install_fixture_key "$TEST_SECOND_USER"
set_state_secret_tell "$TEST_SECOND_USER"

Loading…
Cancel
Save