-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlefthook.yml
More file actions
66 lines (65 loc) · 2.18 KB
/
Copy pathlefthook.yml
File metadata and controls
66 lines (65 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
pre-commit:
parallel: true
commands:
cargo-fmt:
glob: "*.rs"
run: cargo fmt --all -- --check
trailing-whitespace:
run: |
violations=0
for f in $(git diff --cached --name-only); do
if git show ":$f" 2>/dev/null | grep -q '[[:space:]]$'; then
echo "trailing whitespace in: $f"
violations=$((violations + 1))
fi
done
[ "$violations" -eq 0 ] || exit 1
end-of-file-fixer:
run: |
violations=0
for f in $(git diff --cached --name-only | grep -vE '\.(png|jpg|gif|ico|lock|woff2?)$'); do
last=$(git show ":$f" 2>/dev/null | tail -c1 | od -An -tx1 | tr -d ' ')
if [ -n "$last" ] && [ "$last" != "0a" ]; then
echo "no newline at EOF: $f"
violations=$((violations + 1))
fi
done
[ "$violations" -eq 0 ] || exit 1
check-yaml:
run: |
violations=0
for f in $(git diff --cached --name-only | grep -E '\.(yml|yaml)$'); do
if python3 -c "import yaml, sys" 2>/dev/null; then
if git show ":$f" 2>/dev/null | python3 -c "import yaml, sys; yaml.safe_load(sys.stdin)" 2>&1; then
echo "OK: $f"
else
echo "YAML ERROR: $f"
violations=$((violations + 1))
fi
else
if git show ":$f" 2>/dev/null | ruby -ryaml -e 'YAML.load($stdin)' 2>&1; then
echo "OK: $f"
else
echo "YAML ERROR: $f"
violations=$((violations + 1))
fi
fi
done
[ "$violations" -eq 0 ] || exit 1
check-added-large-files:
run: |
violations=0
for f in $(git diff --cached --name-only); do
sha=$(git ls-files -s "$f" | awk '{print $2}')
size=$(git cat-file -s "$sha" 2>/dev/null)
if [ -n "$size" ] && [ "$size" -gt 500000 ]; then
echo "large file staged (>500KB): $f ($size bytes)"
violations=$((violations + 1))
fi
done
[ "$violations" -eq 0 ] || exit 1
pre-push:
parallel: true
commands:
cargo-clippy:
run: cargo clippy --all-features -- -D warnings