Skip to content

Commit f8de160

Browse files
committed
Add pre-commit hook for linting
1 parent ed19fb4 commit f8de160

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ LINT_FILES := setup \
55
lint:
66
shfmt -i 4 -w $(LINT_FILES)
77

8+
install-hook:
9+
cp -f pre-commit .git/hooks/pre-commit
10+
chmod +x .git/hooks/pre-commit
11+
812
default: lint

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ If you want to contribute, please make sure you have `shfmt` installed, and run
1111
`make lint` before commiting. This ensures tabs and spaces does not get mixed,
1212
as well as consistent styling.
1313

14+
Alternatively, you can use our provided hook to run `make lint` automatically
15+
before git commits your changes.
16+
17+
To install the hook:
18+
```bash
19+
make install-hook
20+
```
21+
1422
```bash
1523
# For example, shfmt will ensure:
1624
if condition

pre-commit

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
echo "Running make lint"
4+
make lint
5+
exit $?

0 commit comments

Comments
 (0)