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
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ go test ./...
- **Style**: Standard Go (gofmt, govet). No magic, explicit is better.
- **Errors**: Wrap with context, don't swallow.
- **Tests**: Table-driven, in `_test.go` files alongside code.
- **Commit messages**: Conventional Commits (`<type>(<scope>)?: <description>`), types: `feat, fix, chore, docs, refactor, perf, ci, test, build, style`. Run `make install-hooks` to enforce this locally via `scripts/commit-msg.sh`.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ help:
@echo " check - Run tests and lint"
@echo " install - Build and install to Go bin directory"
@echo " calibrate-providers - Compare local Claude/Codex session usage for calibration"
@echo " install-hooks - Install git pre-commit hook"
@echo " install-hooks - Install git pre-commit and commit-msg hooks"
@echo " help - Show this help"

# Install git pre-commit hook
# Install git pre-commit and commit-msg hooks
install-hooks:
@ln -sf ../../scripts/pre-commit.sh .git/hooks/pre-commit
@echo "✓ pre-commit hook installed (.git/hooks/pre-commit → scripts/pre-commit.sh)"
@ln -sf ../../scripts/commit-msg.sh .git/hooks/commit-msg
@echo "✓ commit-msg hook installed (.git/hooks/commit-msg → scripts/commit-msg.sh)"
31 changes: 31 additions & 0 deletions scripts/commit-msg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# commit-msg hook for nightshift
# Enforces Conventional Commits subject lines: https://www.conventionalcommits.org/
# Install: make install-hooks (or: ln -sf ../../scripts/commit-msg.sh .git/hooks/commit-msg)
set -euo pipefail

MSG_FILE="$1"
SUBJECT=$(head -n1 "$MSG_FILE")

# Allow merge and revert commits through untouched.
if [[ "$SUBJECT" =~ ^Merge\ ]] || [[ "$SUBJECT" =~ ^Revert\ ]]; then
exit 0
fi

TYPES="feat|fix|chore|docs|refactor|perf|ci|test|build|style"
PATTERN="^(${TYPES})(\([a-zA-Z0-9_.-]+\))?!?: .+"

printf "🪡 commit-msg check\n"
printf " %-20s" "conventional commit"

if [[ "$SUBJECT" =~ $PATTERN ]]; then
echo "✓"
else
echo "✗ FAILED"
echo " Subject must match: <type>(<scope>)?: <description>"
echo " Allowed types: ${TYPES//|/, }"
echo " Got: \"$SUBJECT\""
echo ""
echo "❌ commit message does not follow Conventional Commits. Fix it or use --no-verify to skip."
exit 1
fi