Skip to content
Draft
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
23 changes: 23 additions & 0 deletions .github/hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Check commit message
COMMIT_MSG_FILE=".git/COMMIT_EDITMSG"
COMMIT_MSG=$(sed -e 's/[[:space:]]*$//' "$COMMIT_MSG_FILE")

# Bash-compatible regex
REGEX="^\[([a-z]+(/[a-z]+)*)\] (feat|fix|chore|docs|style|refactor|perf|test|build|ci|revert)(\([a-zA-Z0-9_-]+\))?: [a-z].*( \(#([0-9]+)\))?$"

if ! [[ $COMMIT_MSG =~ $REGEX ]]; then
echo "ERROR: Commit message must follow format:"
echo "[categories] type(scope?): description (#issueNumber optional)"
echo "Categories: backend, frontend, tools (can combine with /)"
echo "Conventional types: feat, fix, chore, docs, style, refactor, perf, test, build, ci, revert"
echo "Description must start with and space and after a lowercase letter"
echo "Examples:"
echo "[backend] feat(auth): add login endpoint"
echo "[frontend/tools] fix(ui): correct button color"
echo "[backend/frontend/tools] chore(build): update dependencies (#456)"
exit 1
fi

exit 0
6 changes: 6 additions & 0 deletions .github/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# Apply Spotless
echo "Running Spotless..."
# Uncomment and set your Maven path when ready
# mvn spotless:apply || { echo "Spotless failed! Commit aborted."; exit 1; }