From af851c45b592bd0e1818d9ba51017da2b3cf97f2 Mon Sep 17 00:00:00 2001 From: Bandie Date: Thu, 16 Jun 2022 15:04:24 +0200 Subject: [PATCH] head was missing; catching errors --- genwkdkey | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/genwkdkey b/genwkdkey index 7e60e21..6050252 100755 --- a/genwkdkey +++ b/genwkdkey @@ -4,7 +4,7 @@ read -p 'Type in your chaospott mail address: ' MAILADDRESS # Get WKDHASH -WKDHASH=$(gpg --with-wkd-hash --fingerprint "$MAILADDRESS" | egrep "[ ]{14}[0-9a-z]{32}@chaospott\.de" | sed 's/ //g;s/@chaospott\.de//') +WKDHASH=$(gpg --with-wkd-hash --fingerprint "$MAILADDRESS" | egrep "[ ]{14}[0-9a-z]{32}@chaospott\.de" | head -n1 | sed 's/ //g;s/@chaospott\.de//') if [ -n "$WKDHASH" ]; then # Export key into WKDHASH @@ -12,10 +12,21 @@ if [ -n "$WKDHASH" ]; then git add "$WKDHASH" # git commit and push - echo "OK. Now put your nickname in the commit message." - read -p 'Press enter.' - git commit + read -p 'Enter your nickname: ' NICKNAME + git commit -m "$NICKNAME" + COMMITEXIT=$? git push + if [ $? -ne 0 ]; then + if [ $COMMITEXIT -eq 0 ]; then + git reset HEAD~1 + fi + + echo "git push failed. Try again." + exit 1 + fi + + exit 0 else echo "Mail address is not in your keyring." + exit 1 fi