@ -465,44 +465,31 @@ function _warn_or_abort {
}
function _find_and_remove_secrets {
# required:
local pattern = " $1 " # can be any string pattern
local verbose_opt = ''
if [ [ -n " $_SECRETS_VERBOSE " ] ] ; then
verbose_opt = 'v' ;
fi
local root
root = $( _get_git_root_path)
# shellcheck disable=SC2086
find " $root " -path " $pattern " -type f -print0 | xargs -0 rm -f$verbose_opt
}
function _find_and_remove_secrets_formatted {
# required:
local pattern = " $1 " # can be any string pattern
local outputs
outputs = $( _find_and_remove_secrets " $pattern " )
if [ [ -n " $_SECRETS_VERBOSE " ] ] && [ [ -n " $outputs " ] ] ; then
# shellcheck disable=SC2001
echo " $outputs " | sed "s/^/git-secret: cleaning: /"
fi
local filenames
_list_all_added_files # sets array variable 'filenames'
for filename in " ${ filenames [@] } " ; do
local path # absolute path
encrypted_filename = $( _get_encrypted_filename " $filename " )
if [ [ -f " $encrypted_filename " ] ] ; then
rm " $encrypted_filename "
if [ [ -n " $_SECRETS_VERBOSE " ] ] ; then
echo " git-secret: deleted: $encrypted_filename "
fi
fi
done
}
# this sets the global array variable 'filenames'
function _list_all_added_files {
local path_mappings
path_mappings = $( _get_secrets_dir_paths_mapping)
if [ [ ! -s " $path_mappings " ] ] ; then
_abort " $path_mappings is missing. "
_abort " path_mappings file is missing or empty: $path_mappings "
fi
local filename
@ -540,7 +527,7 @@ function _secrets_dir_is_not_ignored {
ignores = $( _check_ignore " $git_secret_dir " )
if [ [ ! $ignores -eq 1 ] ] ; then
_abort " '$git_secret_dir ' is in .gitignore "
_abort " entry already in .gitignore: $git_secret_dir "
fi
}
@ -783,6 +770,10 @@ function _decrypt {
local encrypted_filename
encrypted_filename = $( _get_encrypted_filename " $filename " )
if [ ! -f " $encrypted_filename " ] ; then
_warn_or_abort " cannot find file to decrypt: $encrypted_filename " "1" " $error_ok "
fi
local args = ( "--use-agent" "--decrypt" )
if [ [ " $write_to_file " -eq 1 ] ] ; then