Supress git errors when the pass store is not a git repo

This commit is contained in:
Peter Cai 2022-10-10 16:16:50 -04:00
parent f9902f8989
commit ca322277b2
1 changed files with 10 additions and 6 deletions

View File

@ -32,6 +32,10 @@ gocrypt_die() {
exit 1
}
_cmd_git() {
[ -d '.git' ] && cmd_git "$@"
}
gocrypt_derive_password() {
local data="$1"
local key="$2"
@ -94,10 +98,10 @@ gocrypt_init() {
echo "# Gocrypt" >> .gitignore
echo "gocrypt" >> .gitignore
cmd_git add .gitignore
$needs_passphrase && cmd_git add "$gocrypt_needs_passphrase_marker"
cmd_git add "$gocrypt_dir"
cmd_git commit -m "Initialized encrypted storage for gocrypt plugin"
_cmd_git add .gitignore
$needs_passphrase && _cmd_git add "$gocrypt_needs_passphrase_marker"
_cmd_git add "$gocrypt_dir"
_cmd_git commit -m "Initialized encrypted storage for gocrypt plugin"
}
gocrypt_open() {
@ -134,8 +138,8 @@ gocrypt_delegate() {
# Delegate command to another `pass` instance that manages what is inside of the mountpoint
PASSWORD_STORE_DIR="$PWD/$gocrypt_dec_dir" "$PROGRAM" "$@"
# Commit if there has been changes due to this operation
cmd_git add "$gocrypt_dir"
cmd_git commit -m "Encrypted pass operation inside gocrypt" "$gocrypt_dir" || echo "No git commit created"
_cmd_git add "$gocrypt_dir"
_cmd_git commit -m "Encrypted pass operation inside gocrypt" "$gocrypt_dir" || echo "No git commit created"
}
gocrypt_crypt() {