git-secret/src/commands/git_secret_killperson.sh

43 lines
989 B
Bash
Raw Normal View History

2016-02-21 13:26:17 +00:00
#!/usr/bin/env bash
function killperson {
OPTIND=1
2016-06-30 19:32:42 +00:00
while getopts 'h' opt; do
case "$opt" in
2016-06-30 19:32:42 +00:00
h) _show_manual_for 'killperson';;
2017-09-28 13:58:07 +00:00
*) _invalid_option_for 'killperson';;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
2016-02-21 13:26:17 +00:00
_user_required
# Command logic:
local emails=( "$@" )
if [[ ${#emails[@]} -eq 0 ]]; then
_abort "at least one email is required for killperson."
2016-02-21 13:26:17 +00:00
fi
# Getting the local git-secret `gpg` key directory:
local secrets_dir_keys
secrets_dir_keys=$(_get_secrets_dir_keys)
for email in "${emails[@]}"; do
$SECRETS_GPG_COMMAND --homedir "$secrets_dir_keys" --no-permission-warning --batch --yes --delete-key "$email"
2018-06-13 18:03:30 +00:00
local exit_code=$?
if [[ "$exit_code" -ne 0 ]]; then
2018-06-13 18:32:15 +00:00
_abort "problem deleting key for '$email' with gpg: exit code $exit_code"
2018-06-13 18:03:30 +00:00
fi
done
echo 'removed keys.'
echo "now [$*] do not have an access to the repository."
echo 'make sure to hide the existing secrets again.'
2016-02-21 13:26:17 +00:00
}