build: add pre-commit hook template

This commit is contained in:
wi11-holdsworth 2025-09-25 21:35:13 +10:00
parent eeae2e69f3
commit d03f1ca906
2 changed files with 22 additions and 1 deletions

11
.pre-commit Normal file
View file

@ -0,0 +1,11 @@
#!/bin/sh
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0
# Prettify all selected files
echo "$FILES" | xargs keep-sorted
# Add back the modified files to staging
echo "$FILES" | xargs git add
exit 0

View file

@ -1 +1,11 @@
# dots
# dots
## build
### `keep-sorted` pre-commit hook
copy the pre-commit hook to `.git/hooks`
```bash
cp .pre-commit .git/hooks/pre-commit
```
make it executable
```bash
chmod +x .git/hooks/pre-commit
```