mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
switching to pre-commit hook
This commit is contained in:
parent
24c40099f0
commit
ed4ecd4dca
2 changed files with 19 additions and 10 deletions
19
.githooks/pre-commit
Executable file
19
.githooks/pre-commit
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# fail if we add any new lines to C or Scheme source containing a tab
|
||||||
|
if git diff --name-only | egrep '\.(cpp|h|scm|sld|stub)$' | xargs -d'\n' git diff -U0 -- | grep -q $'^+ *\t'; then
|
||||||
|
echo "Error: Attempting to add a source file using tabs for indentation."
|
||||||
|
echo
|
||||||
|
echo -n " "
|
||||||
|
git diff --name-only |\
|
||||||
|
egrep '\.(cpp|h|scm|sld|stub)$' |\
|
||||||
|
xargs -d'\n' git diff -U0 -- |\
|
||||||
|
grep $'^+ *\t' | head -1
|
||||||
|
echo
|
||||||
|
cat <<EOF
|
||||||
|
It's important for arguments to line up vertically to a precise column.
|
||||||
|
Since there is no standard tab width, using tabs for indentation makes
|
||||||
|
this impossible in general. Please use spaces.
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
|
fi
|
|
@ -1,10 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
old="$2"
|
|
||||||
new="$3"
|
|
||||||
|
|
||||||
# fail if we add any new lines to C or Scheme source containing a tab
|
|
||||||
git diff --name-only "$old" "$new" |\
|
|
||||||
egrep '\.(cpp|h|scm|sld|stub)$' |\
|
|
||||||
xargs -d'\n' git diff -U0 "$old" "$new" -- |\
|
|
||||||
grep -q $'^+.*\t' && exit 1
|
|
Loading…
Add table
Reference in a new issue