Content-Length: 336243 | pFad | http://github.com/adamcrume/java-properties/commit/2a61e66c0165b42b6f6d8c111f818230d43c0a77

9E Add git pre-commit hook and format the code · adamcrume/java-properties@2a61e66 · GitHub
Skip to content

Commit 2a61e66

Browse files
committed
Add git pre-commit hook and format the code
1 parent 1fbcd1e commit 2a61e66

File tree

3 files changed

+1203
-1011
lines changed

3 files changed

+1203
-1011
lines changed

git-hooks/pre-commit

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if git-rev-parse --verify HEAD >/dev/null 2>&1
6+
then
7+
against=HEAD
8+
else
9+
# Initial commit: diff against an empty tree object
10+
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
11+
fi
12+
13+
function grep-check {
14+
test="$1"
15+
ignore="$2"
16+
msg="$3"
17+
if (git diff --cached | egrep -i "$test" | grep -v IGNORE:"$ignore"); then
18+
echo "Error: $msg (This message can be suppressed by adding the string IGNORE:$ignore to the same line.)"
19+
exit 1
20+
fi
21+
}
22+
23+
function grep-check-case-sensitive {
24+
test="$1"
25+
ignore="$2"
26+
msg="$3"
27+
if (git diff --cached | egrep "$test" | grep -v IGNORE:"$ignore"); then
28+
echo "Error: $msg (This message can be suppressed by adding the string IGNORE:$ignore to the same line.)"
29+
exit 1
30+
fi
31+
}
32+
33+
grep-check-case-sensitive \
34+
NOCOMMIT `#IGNORE:NOCOMMIT` \
35+
NOCOMMIT `#IGNORE:NOCOMMIT` \
36+
"Found a line tagged with NOCOMMIT." # IGNORE:NOCOMMIT
37+
38+
cargo fmt --all -- --check
39+
cargo build --all-targets
40+
cargo test --release
41+
42+
# Check for trailing whitespace
43+
exec git diff-index --check --cached $against --

init-git-hooks

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
mydir="$(dirname "$(readlink -f "$0")")"
4+
ln -s ../../git-hooks/pre-commit "$mydir"/.git/hooks/pre-commit

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/adamcrume/java-properties/commit/2a61e66c0165b42b6f6d8c111f818230d43c0a77

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy