diff --git a/.githooks/commit-msg b/.githooks/commit-msg deleted file mode 100755 index e1def12..0000000 --- a/.githooks/commit-msg +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python - -import sys - -commitmsg = "" - -with open('.git/COMMIT_EDITMSG', mode='r') as f: - commitmsg = f.readline().strip() - -print("Commit message is: " + commitmsg) - -ALLOWED_COMMIT_TYPES = [ - "cicd", - "test", - "refactor", - "depbump", - "typo", - "fmt", - "doc", - "bugfix", - "security", - "feature", -] - -for allowedType in ALLOWED_COMMIT_TYPES: - if commitmsg.startswith(allowedType + ":"): - print("Allowing commit type: ", allowedType) - sys.exit(0) - -print("Commit message should start with commit type. One of: ", ", ".join(ALLOWED_COMMIT_TYPES)) -sys.exit(1) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 4d87839..c67cb3a 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -14,7 +14,7 @@ Helpful information to understand the project can be found here: [CONTRIBUTING]( Please put a X in the boxes as evidence of reading through the checklist. - [ ] I have forked the project, and raised this PR on a feature branch. -- [ ] `make githooks` has been run, and my git commit message was accepted by the git hook. +- [ ] I ran the `pre-commit` hooks, and my commit message was validated. - [ ] `make daemon-compile` runs without any issues. - [ ] `make daemon-codestyle` runs without any issues. - [ ] `make daemon-unittests` runs without any issues. diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fd16ba2..ef5f169 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,19 @@ +--- # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: -- repo: https://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.2.0 hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-added-large-files + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + + # Alternative semantic commit checker + - repo: https://github.com/compilerla/conventional-pre-commit + rev: v3.1.0 + hooks: + - id: conventional-pre-commit + stages: [commit-msg] + args: [] # optional: list of Conventional Commits types to allow e.g. [feat, fix, ci, chore, test] diff --git a/Makefile b/Makefile index ae3baf4..9ac0f78 100644 --- a/Makefile +++ b/Makefile @@ -40,9 +40,6 @@ daemon-unittests: it: cd integration-tests && make -githooks: - git config --local core.hooksPath .githooks - go-tools: go install "github.com/bufbuild/buf/cmd/buf" go install "github.com/fzipp/gocyclo/cmd/gocyclo"