Fixed init committing before .gpg-id created; muted calls to gpg

This commit is contained in:
Vera Lewis
2024-03-31 03:37:30 -05:00
parent a7c57c3779
commit ae90dce106

18
vns
View File

@@ -77,14 +77,10 @@ vns_init () {
echo -n '' > "${VNS_STORE}/.gpg-id"
vns_reencrypt "$VNS_STORE" "$@"
else
# Create a new VNS Store
git init "$VNS_STORE"
# Make initial commit
vns_git add .gpg-id
vns_git commit -am "Initialized VNS Store"
git init "$VNS_STORE" >/dev/null
vns_report "Initialized new VNS store"
fi
@@ -93,6 +89,8 @@ vns_init () {
for recipient in "$@"; do
echo "$recipient" >> "${VNS_STORE}/.gpg-id"
done
vns_git add .gpg-id >/dev/null
vns_git commit -am "Updated GPG recipients" >/dev/null
}
vns_reencrypt () {
@@ -109,7 +107,7 @@ vns_reencrypt () {
# Find all notes and re-encrypt them
find "${VNS_STORE}" -name "*.gpg" | while read -r FILE; do\
gpg --batch -d "$FILE" 2>/dev/null | gpg --batch "${GPG_RECIPS[@]}" -e -o "${FILE}_new".gpg >/dev/null 2>&1
gpg --batch --decrypt "$FILE" 2>/dev/null | gpg --batch "${GPG_RECIPS[@]}" --encrypt --output "${FILE}_new".gpg >/dev/null 2>&1
mv "${FILE}_new.gpg" "$FILE";
done
@@ -237,7 +235,7 @@ vns_create () {
# Create empty note
mkdir -p "$(dirname "$VNS_STORE/$1.gpg")"
vns_header "$(basename "$1")" | gpg --batch "$(vns_gpgid)" --encrypt -o "$VNS_STORE/$1.gpg"
vns_header "$(basename "$1")" | gpg --batch "$(vns_gpgid)" --encrypt -o "$VNS_STORE/$1.gpg" 2>/dev/null
# Edit the note
vim "$VNS_STORE/$1.gpg"
@@ -352,10 +350,6 @@ vns_merge () {
if [ -r "$VNS_STORE/$1.gpg" ]; then vns_raise "Output file already exists." 82; fi
if [ ! -r "$VNS_STORE/$2.gpg" ]; then vns_raise "Could not read $2" 83; fi
#local GPG_OPTS=()
#for recip in $(gpg --list-only -v -d "${VNS_STORE}/$2.gpg" 2>&1 | awk '/public key is/{print $5}'); do
# GPG_OPTS=( "${GPG_OPTS[@]}" -r "$recip" )
#done
local -r NOTE_NAME="$1"
local -r OUTPUT="${VNS_STORE}/${1}.gpg"
shift