Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix for 'reveal' in a subdir (#903) #905

Merged
merged 1 commit into from
Jul 19, 2022
Merged
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
4 changes: 3 additions & 1 deletion src/commands/git_secret_reveal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ function reveal {

local counter=0
local to_show=( "$@" )
local path_prepend_func='_prepend_relative_root_path'

if [ ${#to_show[@]} -eq 0 ]; then
path_prepend_func='_prepend_root_path'
while read -r record; do
to_show+=("$record") # add record to array
done < "$path_mappings"
Expand All @@ -55,7 +57,7 @@ function reveal {
local filename
local path
filename=$(_get_record_filename "$line")
path=$(_prepend_relative_root_path "$filename") # this uses the _relative version because of #710
path=$("$path_prepend_func" "$filename")

if [[ "$filename" == *"$SECRETS_EXTENSION" ]]; then
_abort "cannot decrypt to secret version of file: $filename"
Expand Down
22 changes: 22 additions & 0 deletions tests/test_reveal.bats
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,25 @@ function teardown {
# clean up
rm -rf subdir
}

@test "run 'reveal' for all files from subdir" {
local password
password=$(test_user_password "$TEST_DEFAULT_USER")

mkdir -p subdir
echo "content2" > subdir/new_filename.txt

( # start subshell for subdir tests
cd subdir
run git secret add new_filename.txt
[ "$status" -eq 0 ]
run git secret hide
[ "$status" -eq 0 ]

run git secret reveal -d "$TEST_GPG_HOMEDIR" -p "$password"
sobolevn marked this conversation as resolved.
Show resolved Hide resolved
[ "$status" -eq 0 ]
) # end subshell

# clean up
rm -rf subdir
}