Skip to content
Merged
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
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# templates/flow-v2-shared/sync-tools.sh.
exclude: ^templates/flow-v2-shared/tools/

default_install_hook_types: [pre-commit, commit-msg]

repos:
# Ruff for formatting and linting
- repo: https://github.com/astral-sh/ruff-pre-commit
Expand Down Expand Up @@ -41,3 +43,12 @@ repos:
types: [python]
pass_filenames: false
stages: [manual] # Run only with: pre-commit run --hook-stage manual pyright

# Mirrors .github/workflows/conventional-commits.yml's commit-message check.
# (The PR-title half of that workflow can't be checked locally — GitHub
# only knows the PR title once the PR exists.)
- id: conventional-commit-msg
name: conventional commit message
entry: scripts/check_commit_msg.sh
language: script
stages: [commit-msg]
21 changes: 21 additions & 0 deletions scripts/check_commit_msg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Enforces Conventional Commits locally, mirroring .github/workflows/conventional-commits.yml.
set -euo pipefail

MSG_FILE="$1"
MSG="$(head -n1 "$MSG_FILE")"
PATTERN='^(feat|fix|refactor|docs|style|test|chore|perf|ci|build|revert)(\([a-z0-9._/-]+\))?(!)?: .+'

if echo "$MSG" | grep -Eq '^Merge (pull request|branch|remote-tracking)'; then
exit 0
fi

if ! echo "$MSG" | grep -Eq "$PATTERN"; then
echo "ERROR: commit message does not follow Conventional Commits."
echo " Got: $MSG"
echo " Expected: <type>[optional scope]: <description>"
echo " Types: feat | fix | refactor | docs | style | test | chore | perf | ci | build | revert"
echo " Examples: feat(sandbox): add preservation mode"
echo " fix: handle empty dataset gracefully"
exit 1
fi
Loading