From b103e47fecb0f3a98955b59c285abf604fce4e24 Mon Sep 17 00:00:00 2001 From: bp99 Date: Tue, 28 Jul 2026 18:49:21 +0200 Subject: [PATCH] feat: add conventional-commits-bp99 commit-msg hook --- ...onventional-commits-v1.0.0-bp99.commit-msg | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 commit-msg/conventional-commits-v1.0.0-bp99.commit-msg diff --git a/commit-msg/conventional-commits-v1.0.0-bp99.commit-msg b/commit-msg/conventional-commits-v1.0.0-bp99.commit-msg new file mode 100755 index 0000000..ff52bd7 --- /dev/null +++ b/commit-msg/conventional-commits-v1.0.0-bp99.commit-msg @@ -0,0 +1,34 @@ +#!/bin/sh -euC +# +# Reject commit messages that do not conform to Conventional Commits. +# +# Enforces Conventional Commits v1.0.0 at the syntactic level. +# Also enforces a custom list of types. +# +# Upstream: gitea.bp99.eu/bp99/git-hooks + +types='feat|fix|build|chore|ci|docs|style|refactor|test|perf|merge|revert' + +subject="$(sed -n 1p "$1")" +second="$(sed -n 2p "$1")" + +fail() { + >&2 cat <[()][!]: + types: $types + +Bypass with: git commit --no-verify +EOF + exit 1 +} + + +# type, optional (scope), optional !, terminal ': ', non-emtpy desc +printf '%s' "$subject" | grep -Eq "^($types)(\([^()]+\))?!?: .+" \ +|| fail 'subject does not conform to Conventional Commits' + +# Body must begin one blank line after description +[ -z "$second" ] || fail 'Line 2 must be blank'