Added '-f' option to the `reveal` command.

This option allows to easily overwite existing giles with no prompt.
Also added documentation for the new option.

Closes #24
pull/27/head
sobolevn 8 years ago
parent a8c244b319
commit 8206de7ebb

@ -3,7 +3,7 @@ git-secret-reveal - decrypts all added files.
## SYNOPSIS ## SYNOPSIS
git secret reveal [-d dir] [-p password] git secret reveal [-f] [-d dir] [-p password]
## DESCRIPTION ## DESCRIPTION
@ -12,6 +12,7 @@ git-secret-reveal - decrypts all added files.
## OPTIONS ## OPTIONS
-f - forces to overwrite exisiting files without prompt.
-d - specifies `--homedir` option for the `gpg`, basically use this option if your store your keys in a custom location. -d - specifies `--homedir` option for the `gpg`, basically use this option if your store your keys in a custom location.
-p - specifies password for noinput mode, adds `--passphrase` option for `gpg`. -p - specifies password for noinput mode, adds `--passphrase` option for `gpg`.
-h - shows help. -h - shows help.

@ -6,11 +6,14 @@ function reveal {
OPTIND=1 OPTIND=1
local homedir="" local homedir=""
local passphrase="" local passphrase=""
local force=0
while getopts "hd:p:" opt; do while getopts "hfd:p:" opt; do
case "$opt" in case "$opt" in
h) _show_manual_for "reveal";; h) _show_manual_for "reveal";;
f) force=1;;
p) passphrase=$OPTARG;; p) passphrase=$OPTARG;;
d) homedir=$OPTARG;; d) homedir=$OPTARG;;
@ -26,7 +29,12 @@ function reveal {
while read line; do while read line; do
local encrypted_filename=$(_get_encrypted_filename "$line") local encrypted_filename=$(_get_encrypted_filename "$line")
local base="$SECRETS_GPG_COMMAND --use-agent -q --decrypt --yes" local base="$SECRETS_GPG_COMMAND --use-agent -q --decrypt"
if [[ "$force" -eq 1 ]]; then
base="$base --yes"
fi
if [[ ! -z "$homedir" ]]; then if [[ ! -z "$homedir" ]]; then
base="$base --homedir=$homedir" base="$base --homedir=$homedir"
fi fi

@ -42,6 +42,17 @@ function teardown {
} }
@test "run 'reveal' with '-f'" {
rm -f "$FILE_TO_HIDE"
local password=$(test_user_password "$TEST_DEFAULT_USER")
run git secret reveal -f -d "$TEST_GPG_HOMEDIR" -p "$password"
[ "$status" -eq 0 ]
[ -f "$FILE_TO_HIDE" ]
}
@test "run 'reveal' with wrong password" { @test "run 'reveal' with wrong password" {
rm -f "$FILE_TO_HIDE" rm -f "$FILE_TO_HIDE"

Loading…
Cancel
Save