forked from ingonyama-zk/icicle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-push
executable file
·47 lines (41 loc) · 2.24 KB
/
pre-push
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
#!/bin/bash
status=0
if [[ $(codespell --skip ./**/target,./**/build,./docs/*.js,./docs/*.json -I .codespellignore 2>&1) ]];
then
echo "There are typos in some of the files you've changed. Please run the following to check what they are:"
echo "codespell --skip ./**/target,./**/build,./docs/*.js,./docs/*.json -I .codespellignore"
echo ""
status=1
fi
# Run clang-format on CUDA, C, and CPP files
# clang-format writes to stderr in dry-run mode. In order to capture the output to detect if there are changes needed we redirect stderr to stdin
if [[ $(find ./ \( -path ./icicle/build -prune -o -path ./**/target -prune -o -path ./examples -prune \) -iname *.h -or -iname *.cuh -or -iname *.cu -or -iname *.c -or -iname *.cpp | xargs clang-format --dry-run -ferror-limit=1 -style=file 2>&1) ]];
then
echo "🚨 There are files in Icicle Core that need formatting."
echo ""
echo "Please format all .c, .cpp, .h, .cu, .cuh files using the following command:"
echo "find ./ \( -path ./icicle/build -prune -o -path ./**/target -prune -o -path ./examples -prune \) -iname *.h -or -iname *.cuh -or -iname *.cu -or -iname *.c -or -iname *.cpp | xargs clang-format -i -style=file"
echo ""
echo "If you only want to see what formatting is required please run:"
echo "find ./ \( -path ./icicle/build -prune -o -path ./**/target -prune -o -path ./examples -prune \) -iname *.h -or -iname *.cuh -or -iname *.cu -or -iname *.c -or -iname *.cpp | xargs clang-format --dry-run -style=file"
echo ""
status=1
fi
# Run go fmt across all Golang packages
if [[ $(go list ./... | xargs go fmt) ]];
then
echo "🚨 There are Golang files that need formatting."
echo "Please commit the formatted files"
echo ""
status=1
fi
# Run cargo fmt on Rust files
cd wrappers/rust
if [[ $(find . -path ./icicle-curves/icicle-curve-template -prune -o -name target -prune -o -iname *.rs -print | xargs cargo fmt --check --) ]];
then
echo "🚨 There are Rust files that need formatting."
echo "Please go to wrappers/rust and format the Rust files using the following command:"
echo "find . -path ./icicle-curves/icicle-curve-template -prune -o -name target -prune -o -iname *.rs -print | xargs cargo fmt --check --"
status=1
fi
exit $status