Skip to content

Commit 26a73a1

Browse files
committed
feat(git): add pre-commit hooks
1 parent d99cc8e commit 26a73a1

3 files changed

Lines changed: 103 additions & 0 deletions

File tree

.pre-commit-config.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Pre-commit configuration using prek's built-in fast hooks
2+
# See https://github.com/j178/prek for more information
3+
4+
repos:
5+
# Built-in Rust hooks (fast, zero-setup)
6+
- repo: builtin
7+
hooks:
8+
# Fix trailing whitespace (preserve markdown line breaks)
9+
- id: trailing-whitespace
10+
args: ['--markdown-linebreak-ext=md,markdown']
11+
12+
# Ensure files end with newline
13+
- id: end-of-file-fixer
14+
15+
# Check for accidentally committed large files
16+
- id: check-added-large-files
17+
args: ['--maxkb=500']
18+
19+
# Validate YAML files
20+
- id: check-yaml
21+
22+
# Validate TOML files
23+
- id: check-toml
24+
25+
# Normalize line endings to LF
26+
- id: mixed-line-ending
27+
args: ['--fix=lf']
28+
29+
# Detect accidentally committed private keys
30+
- id: detect-private-key
31+
32+
# Prevent direct commits to main/master
33+
- id: no-commit-to-branch
34+
args: ['--branch=main', '--branch=master']
35+
36+
# Detect merge conflict markers
37+
- id: check-merge-conflict
38+
39+
# Check for case conflicts (macOS/Windows compatibility)
40+
- id: check-case-conflict
41+
42+
# Remove UTF-8 byte order marker
43+
- id: fix-byte-order-marker
44+
45+
# Local hooks using make commands
46+
- repo: local
47+
hooks:
48+
# Run linting via make
49+
- id: make-lint
50+
name: Run make lint
51+
entry: make lint
52+
language: system
53+
types: [python]
54+
pass_filenames: false
55+
stages: [pre-commit]
56+
57+
# Run formatting via make
58+
- id: make-format
59+
name: Run make format
60+
entry: make format
61+
language: system
62+
pass_filenames: false
63+
stages: [pre-commit]
64+
65+
# Commitizen for conventional commit validation
66+
- repo: https://github.com/commitizen-tools/commitizen
67+
rev: v4.2.0
68+
hooks:
69+
- id: commitizen
70+
stages: [commit-msg]
71+
72+
# Global configuration
73+
fail_fast: false
74+
default_stages: [pre-commit]

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dev = [
3333
"mdformat-gfm>=1",
3434
"mdformat-gfm-alerts>=2",
3535
"mdformat-simple-breaks>=0.0.1",
36+
"prek>=0.3.1",
3637
"pyproject-fmt>=2.11.1",
3738
"ruff>=0.14.13",
3839
"ty>=0.0.12",
@@ -50,3 +51,5 @@ markers = [ "dev: marks tests that are currently developed" ]
5051
[tool.commitizen]
5152
name = "cz_conventional_commits"
5253
version_provider = "pep621"
54+
schema_pattern = "^(feat|fix|docs|chore|test|refactor|perf|ci|build|style)(\\((.*?)\\))?!?:\\s.+"
55+
message_max_length = 72

uv.lock

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)