Skip to content

Instantly share code, notes, and snippets.

Avatar
👻
Boo!

Erik van der Wal erikvdwal

👻
Boo!
View GitHub Profile
@erikvdwal
erikvdwal / prepare-commit-msg
Last active Nov 6, 2018
Git hook to automatically prepend Jira ticket id to commit
View prepare-commit-msg
#!/bin/sh
COMMIT_FILE=$1
COMMIT_MSG=$(cat $1)
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
JIRA_ID=$(echo "$CURRENT_BRANCH" | grep -Eo "[A-Z0-9]{1,10}-?[A-Z0-9]+-\d+")
IN_COMMIT=$(grep -c "$JIRA_ID:" $1)
if ! [[ $IN_COMMIT -ge 1 ]] && [ ! -z "$JIRA_ID" ]; then
echo "$JIRA_ID: $COMMIT_MSG" > $COMMIT_FILE
View gist:a794f6d7fd3b51da7be0
### Keybase proof
I hereby claim:
* I am erikvdwal on github.
* I am erikvdwal (https://keybase.io/erikvdwal) on keybase.
* I have a public key whose fingerprint is FDED 9F7A 7D84 B3C1 826A 8630 F0AD D5B7 F534 5ABD
To claim this, I am signing this object: