cfg/bin/git-c
Knut Ahlers 542937d93f
Add error handling to git-* scripts
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2017-07-17 11:55:39 +02:00

39 lines
827 B
Bash
Executable file

#!/bin/bash -e
set -o pipefail
set -e
STEP_COLOR="\033[0;36m"
NO_COLOR="\033[0m"
function step {
echo -e ${STEP_COLOR}[$(date +%H:%M:%S)] $1${NO_COLOR}
}
### Fix committer email by repo
step "Ensure correct committer email..."
git setmail
### Commit
step "Loading passphrase for GPG key..."
vault-gpg $(git config user.signingkey)
step "Execute pre-commit auto-hook"
git autohook pre-commit
step "Issuing commit..."
git commit -S -s -v "$@"
step "Execute post-commit auto-hook"
git autohook post-commit
### Count productivity habit
step "Recording work..."
PROD_TASK=$(habitica https://habitica.com/api/v3/tasks/user | jq -r '.data | map(select(.text=="productivity").id)[0]')
if ! ( habitica -sS -o /dev/null -X POST https://habitica.com/api/v3/tasks/${PROD_TASK}/score/up ); then
echo "Scoring failed."
fi