refactor: Switch to conventional scripts, rather than custom script (#535)

This commit is contained in:
James Read 2025-03-20 23:04:36 +00:00 committed by GitHub
parent 1275934ac1
commit 6b9c6c8b9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 40 deletions

View File

@ -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)

View File

@ -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. 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. - [ ] 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-compile` runs without any issues.
- [ ] `make daemon-codestyle` runs without any issues. - [ ] `make daemon-codestyle` runs without any issues.
- [ ] `make daemon-unittests` runs without any issues. - [ ] `make daemon-unittests` runs without any issues.

View File

@ -1,10 +1,19 @@
---
# See https://pre-commit.com for more information # See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks # See https://pre-commit.com/hooks.html for more hooks
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0 rev: v3.2.0
hooks: hooks:
- id: trailing-whitespace - id: trailing-whitespace
- id: end-of-file-fixer - id: end-of-file-fixer
- id: check-yaml - id: check-yaml
- id: check-added-large-files - 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]

View File

@ -40,9 +40,6 @@ daemon-unittests:
it: it:
cd integration-tests && make cd integration-tests && make
githooks:
git config --local core.hooksPath .githooks
go-tools: go-tools:
go install "github.com/bufbuild/buf/cmd/buf" go install "github.com/bufbuild/buf/cmd/buf"
go install "github.com/fzipp/gocyclo/cmd/gocyclo" go install "github.com/fzipp/gocyclo/cmd/gocyclo"