Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .git-hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -e

npx --yes @commitlint/cli@20.4.3 --edit "$1"
29 changes: 29 additions & 0 deletions .github/workflows/commit-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Commit Message Check

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
commit-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Validate commit messages
run: |
set -eo pipefail
commits=$(git log --no-merges --pretty=format:"%H" "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}")
for sha in $commits; do
tmp=$(mktemp)
git log -1 --pretty=format:"%B" "$sha" > "$tmp"
npx --yes @commitlint/cli@20.4.3 --edit "$tmp"
rm "$tmp"
done
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ This microservice is built on Java, Spring boot framework and MySQL DB.
* Spring Tool Suite 3 / Eclipse(2023-03)
* Maven (if not pre-installed with the editor)
* Redis-x64-3.0.504
* MySQL Workbench 8.0
* MySQL Workbench 8.0
* Node.js and npm (required for git hooks via npx/commitlint)

## Setting Up Commit Hooks
Enable git hooks (run once after cloning):
- Run the command `git config core.hooksPath .git-hooks`.
35 changes: 35 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module.exports = {
rules: {
'body-leading-blank': [1, 'always'],
'body-max-line-length': [2, 'always', 100],
'footer-leading-blank': [1, 'always'],
'footer-max-line-length': [2, 'always', 100],
'header-max-length': [2, 'always', 100],
'subject-case': [
2,
'never',
['sentence-case', 'start-case', 'pascal-case', 'upper-case'],
],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-enum': [
2,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
],
],
},
};