From 0007652e68f44b3e65b0bc3b2c7cbb69ce5a6b69 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Fri, 2 Apr 2021 14:45:04 +0200 Subject: [PATCH] [#2] Fixed commit hook --- .hooks/commit-msg | 7 ++++--- .hooks/pre-commit | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.hooks/commit-msg b/.hooks/commit-msg index ec6c4c9..81ec68e 100755 --- a/.hooks/commit-msg +++ b/.hooks/commit-msg @@ -10,9 +10,10 @@ issue_num=`echo "$branch" | grep -Po '^[0-9]+(?=-)'` 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; + >&2 echo "Couldn't derive issue number from branch. Please add one manually."; + exit 1; } - # Append issue number - echo "(#$issue_num)" >> "$1" + # Append issue number, and remove all comments + echo "[#$issue_num]" "$(cat "$1")" > "$1" fi diff --git a/.hooks/pre-commit b/.hooks/pre-commit index 0072f2c..3bd0b24 100755 --- a/.hooks/pre-commit +++ b/.hooks/pre-commit @@ -5,10 +5,10 @@ branch=`git rev-parse --abbrev-ref HEAD` -# Just lint the code before committing -make lint - # TODO should we add release branches here as well? if [[ "$branch" =~ ^master|develop$ ]]; then - make test + make test > /dev/null 2>&1 || { + >&2 echo "Tests failed. check 'make test' for more info."; + exit 1; + } fi