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
git secret reveal [-d dir] [-p password]
git secret reveal [-f] [-d dir] [-p password]
## DESCRIPTION
@ -12,6 +12,7 @@ git-secret-reveal - decrypts all added files.
## 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.
-p - specifies password for noinput mode, adds `--passphrase` option for `gpg`.
-h - shows help.

@ -6,11 +6,14 @@ function reveal {
OPTIND=1
local homedir=""
local passphrase=""
local force=0
while getopts "hd:p:" opt; do
while getopts "hfd:p:" opt; do
case "$opt" in
h) _show_manual_for "reveal";;
f) force=1;;
p) passphrase=$OPTARG;;
d) homedir=$OPTARG;;
@ -26,7 +29,12 @@ function reveal {
while read line; do
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
base="$base --homedir=$homedir"
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" {
rm -f "$FILE_TO_HIDE"

Loading…
Cancel
Save