add -c (preserve permission) option to reveal. For #172

pull/245/head
joshr 6 years ago
parent bbcd50e563
commit 2e7d6a12a5

@ -3,7 +3,7 @@ git-secret-reveal - decrypts all added files.
## SYNOPSIS
git secret reveal [-f] [-d dir] [-p password]
git secret reveal [-f] [-c] [-d dir] [-p password]
## DESCRIPTION
@ -18,6 +18,7 @@ Under the hood, this uses the `gpg --decrypt` command.
-f - forces to overwrite existing files without prompt.
-d - specifies `--homedir` option for the `gpg`, basically use this option if you store your keys in a custom location.
-p - specifies password for noinput mode, adds `--passphrase` option for `gpg`.
-c - attempts to set decrypted file to same permissions as encrypted file (normally would be -p but that's used above).
-h - shows help.

@ -5,15 +5,18 @@ function reveal {
local homedir=''
local passphrase=''
local force=0
local chmod=0
OPTIND=1
while getopts 'hfd:p:' opt; do
while getopts 'chfd:p:' opt; do
case "$opt" in
h) _show_manual_for 'reveal';;
f) force=1;;
c) chmod=1;;
p) passphrase=$OPTARG;;
d) homedir=$OPTARG;;
@ -46,6 +49,12 @@ function reveal {
_abort "cannot find decrypted version of file: $filename"
fi
if [[ "$chmod" ]]; then
local perms
perms=$(stat -f "%Op" "$filename")
chmod "$perms" "$path"
fi
counter=$((counter+1))
done < "$path_mappings"

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

Loading…
Cancel
Save