mirror of
https://github.com/sobolevn/git-secret
synced 2024-11-18 15:26:58 +00:00
Add verbose option to 'git secret tell' showing output of key imports (#321)
* add 'git secret tell -v' option to show output of key imports * add tests for tell with/without -v * remove unneeded test code and bats diagnostic output
This commit is contained in:
parent
6e43cd310f
commit
65fe4c4127
@ -21,13 +21,16 @@ function tell {
|
|||||||
local emails
|
local emails
|
||||||
local self_email=0
|
local self_email=0
|
||||||
local homedir
|
local homedir
|
||||||
|
local verbose=0
|
||||||
|
|
||||||
# A POSIX variable
|
# A POSIX variable
|
||||||
# Reset in case getopts has been used previously in the shell.
|
# Reset in case getopts has been used previously in the shell.
|
||||||
OPTIND=1
|
OPTIND=1
|
||||||
|
|
||||||
while getopts "hmd:" opt; do
|
while getopts "vhmd:" opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
|
v) verbose=1;;
|
||||||
|
|
||||||
h) _show_manual_for "tell";;
|
h) _show_manual_for "tell";;
|
||||||
|
|
||||||
m) self_email=1;;
|
m) self_email=1;;
|
||||||
@ -95,7 +98,13 @@ function tell {
|
|||||||
# Importing public key to the local keychain:
|
# Importing public key to the local keychain:
|
||||||
local secrets_dir_keys
|
local secrets_dir_keys
|
||||||
secrets_dir_keys=$(_get_secrets_dir_keys)
|
secrets_dir_keys=$(_get_secrets_dir_keys)
|
||||||
$SECRETS_GPG_COMMAND --homedir "$secrets_dir_keys" --no-permission-warning --import "$keyfile" > /dev/null 2>&1
|
|
||||||
|
local args=( --homedir "$secrets_dir_keys" --no-permission-warning --import "$keyfile" )
|
||||||
|
if [[ "$verbose" -ne 0 ]]; then
|
||||||
|
$SECRETS_GPG_COMMAND "${args[@]}"
|
||||||
|
else
|
||||||
|
$SECRETS_GPG_COMMAND "${args[@]}" > /dev/null 2>&1
|
||||||
|
fi
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
if [[ "$exit_code" -ne 0 ]]; then
|
if [[ "$exit_code" -ne 0 ]]; then
|
||||||
_abort "problem importing public key for '$email' with gpg: exit code $exit_code"
|
_abort "problem importing public key for '$email' with gpg: exit code $exit_code"
|
||||||
|
@ -17,6 +17,25 @@ function teardown {
|
|||||||
unset_current_state
|
unset_current_state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "run 'tell' with '-v'" {
|
||||||
|
run git secret tell -d "$TEST_GPG_HOMEDIR" -v "$TEST_DEFAULT_USER"
|
||||||
|
#echo "$output" | sed "s/^/# '$BATS_TEST_DESCRIPTION' output: /" >&3
|
||||||
|
|
||||||
|
[[ "$output" == *"created"* ]]
|
||||||
|
[[ "$output" == *"gpg:"* ]]
|
||||||
|
[[ "$output" == *"$TEST_DEFAULT_USER"* ]]
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "run 'tell' without '-v'" {
|
||||||
|
run git secret tell -d "$TEST_GPG_HOMEDIR" "$TEST_DEFAULT_USER"
|
||||||
|
#echo "$output" | sed "s/^/# '$BATS_TEST_DESCRIPTION' output: /" >&3
|
||||||
|
|
||||||
|
[[ "$output" != *"imported:"* ]]
|
||||||
|
[[ "$output" == *"$TEST_DEFAULT_USER"* ]]
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
@test "run 'tell' on substring of emails" {
|
@test "run 'tell' on substring of emails" {
|
||||||
run git secret tell -d "$TEST_GPG_HOMEDIR" user
|
run git secret tell -d "$TEST_GPG_HOMEDIR" user
|
||||||
# this should give an error because there is no user named 'user',
|
# this should give an error because there is no user named 'user',
|
||||||
|
Loading…
Reference in New Issue
Block a user