Wrote two git hooks

(#2)
master^2
Jef Roosens 2021-04-02 14:03:20 +02:00
parent c32c9035d8
commit 6acbb4ad62
Signed by: Jef Roosens
GPG Key ID: B580B976584B5F30
2 changed files with 22 additions and 0 deletions

18
.hooks/commit-msg 100755
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
# This hook checks if the commit message ends with an issue number, and if not,
# tries to derive that number from the branch name
branch=`git rev-parse --abbrev-ref HEAD`
issue_num=`echo "$branch" | grep -Po '^[0-9]+(?=-)'`
# Check if issue number is already present
if ! grep -q '([0-9]\+)$' "$1"; then
# Error out if we can't derive issue number
[[ -z "$issue_num" ]] && {
>&2 echo "Couldn't derive issue number from branch. Please add one manually."; exit 1;
}
# Append issue number
echo "(#$issue_num)" >> "$1"
fi

View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
# Just lint the code before committing
make lint