Skip to content

Commit c011386

Browse files
committed
docs: update git hooks documentation in README and install script
1 parent c699726 commit c011386

2 files changed

Lines changed: 35 additions & 3 deletions

File tree

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,23 @@ We welcome issues and PRs! See [CONTRIBUTING](CONTRIBUTING.md) for coding standa
8989

9090
### Git hooks
9191

92-
Repository hooks live in `.githooks`. Run `./scripts/install-git-hooks.sh` once to point `core.hooksPath` there. Hooks enforce Conventional Commits and run `fmt` (writes changes), `clippy`, and `test` before each commit (set `SKIP_PRE_COMMIT=1` to bypass locally).
92+
Repository hooks live in `.githooks`. Run `./scripts/install-git-hooks.sh` once to point `core.hooksPath` there.
93+
94+
The repository includes three git hooks:
95+
96+
1. **`commit-msg`** — Validates commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) specification at commit time
97+
2. **`pre-commit`** — Runs `cargo fmt` (writes changes), `cargo clippy`, and `cargo test` before each commit (set `SKIP_PRE_COMMIT=1` to bypass locally)
98+
3. **`pre-push`** — Validates all commits being pushed follow Conventional Commits, preventing malformed commits from reaching the remote (e.g., those that bypassed `commit-msg` during rebases)
99+
100+
Both `commit-msg` and `pre-push` use shared validation logic from `validate-commit-msg.sh` to ensure consistent enforcement.
101+
102+
Valid commit types: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`
103+
104+
Example commit messages:
105+
106+
- `feat: add new feature`
107+
- `fix(ui): correct button alignment`
108+
- `docs: update README`
93109

94110
## FAQ
95111

scripts/install-git-hooks.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
#!/usr/bin/env bash
12
# SPDX-License-Identifier: MIT
23
# SPDX-FileCopyrightText: 2025 Alexander Minges
34

4-
#!/usr/bin/env bash
55
set -euo pipefail
66

77
# Install repository-provided hooks by pointing git to .githooks.
@@ -12,4 +12,20 @@ ROOT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
1212
echo "Configuring git hooks path to .githooks"
1313
git config core.hooksPath "$ROOT_DIR/.githooks"
1414

15-
echo "Done. Existing hooks were not overwritten; git now reads from .githooks/"
15+
echo ""
16+
echo "Git hooks installed successfully!"
17+
echo ""
18+
echo "The following hooks are now active:"
19+
echo " • commit-msg — Validates Conventional Commits format at commit time"
20+
echo " • pre-commit — Runs cargo fmt, clippy, and test before each commit"
21+
echo " • pre-push — Validates all commits before pushing to remote"
22+
echo ""
23+
echo "All hooks use shared validation logic from validate-commit-msg.sh"
24+
echo ""
25+
echo "Valid commit types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert"
26+
echo "Example: feat: add new feature"
27+
echo " fix(ui): correct button alignment"
28+
echo ""
29+
echo "To bypass pre-commit hook locally: SKIP_PRE_COMMIT=1 git commit"
30+
echo "Note: commit-msg and pre-push hooks cannot be bypassed with --no-verify"
31+
echo " to maintain commit message quality."

0 commit comments

Comments
 (0)