Skip to content

Commit 0aca36e

Browse files
committed
Add a pre-commit hook (fix #9)
1 parent e43e804 commit 0aca36e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@ $ (cd utils; ./sqldep_to_schema_dot) <demo/data/all.dep |dot -Tsvg >demo/data/sc
5252
$ cd demo/data
5353
$ make
5454
```
55+
56+
### Fully automatic
57+
58+
Checks can be run before each commit using a pre-commit hook.
59+
Please install [`hooks/pre-commit`](hooks/pre-commit)
60+
into each of your repositories' `.git/hooks`.

hooks/pre-commit

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
# Redirect output to stderr.
4+
exec 1>&2
5+
6+
DATA=$(git config hooks.projectdata)
7+
if [ -z "$DATA" ]; then
8+
echo error: please configure the data root in hooks.projectdata >&2
9+
exit 1
10+
fi
11+
12+
PROJECT=$(basename "$(git rev-parse --show-toplevel)")
13+
if ! grep "all.dep:.* $PROJECT\.dep" $DATA/Makefile >/dev/null; then
14+
echo warning: this project is NOT analyzed by sqldep >&2
15+
fi
16+
17+
(cd $DATA && make check)

0 commit comments

Comments
 (0)