From 51be90a152071e95563caf89419c4e956509a509 Mon Sep 17 00:00:00 2001 From: Tomas Peterka Date: Mon, 26 Feb 2024 13:48:02 +0100 Subject: [PATCH] feat: add conventional commit check --- .pre-commit-hooks.yaml | 11 +++++++++++ README.md | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index c0d811c..5cbc3f0 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -95,6 +95,17 @@ entry: check-yaml language: python types: [yaml] + +- id: conventional-commit-msg + name: conventional commit message + # type(scope)?: description (body)? (footer)? (lowercase, present tense, and no period at the end) + language: pygrep + entry: '^(chore|test|feat|fix|build|docs|refactor)!?(\([a-z]+\))?: (?![A-Z][a-z])(?![a-z]+(ed|ing)\s).*$' + args: + - --multiline + - --negate # fails if the entry is NOT matched + stages: [commit-msg] + - id: debug-statements name: debug statements (python) description: checks for debugger imports and py37+ `breakpoint()` calls in python source. diff --git a/README.md b/README.md index 9ae7ec5..4ecd40b 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,12 @@ Attempts to load all yaml files to verify syntax. portability to other yaml implementations. Implies `--allow-multiple-documents`. +#### `conventional-commit-msg` +Check if the top line of a commit message follows the +[conventional rules](https://www.conventionalcommits.org/en/v1.0.0/). +The message is expected in format: `type(scope)?: description (body)? (footer)?` +Where description is in lowercase, present tense, and no period at the end. + #### `debug-statements` Check for debugger imports and py37+ `breakpoint()` calls in python source.