#!/bin/bash

set -euo pipefail

source "${HOME}/bin/script_framework.sh"

### Fix committer email by repo

step "Ensure correct commit config..."
git committerconfig

### 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..."
COMMIT_OPTS=$(git config --get commit.cliopts 2>/dev/null || echo "")
git commit -v ${COMMIT_OPTS} "$@"

step "Execute post-commit auto-hook"
git autohook post-commit