mirror of
https://github.com/status-im/go-waku.git
synced 2025-01-26 21:49:26 +00:00
parent
eadd018ce5
commit
4227a9d69d
@ -72,6 +72,11 @@ To build and test this repository, you need:
|
|||||||
- [protoc](https://grpc.io/docs/protoc-installation/)
|
- [protoc](https://grpc.io/docs/protoc-installation/)
|
||||||
- [Protocol Buffers for Go with Gadgets](https://github.com/gogo/protobuf)
|
- [Protocol Buffers for Go with Gadgets](https://github.com/gogo/protobuf)
|
||||||
|
|
||||||
|
To enable the git hooks:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git config core.hooksPath hooks
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
Licensed and distributed under either of
|
Licensed and distributed under either of
|
||||||
|
32
hooks/pre-commit
Executable file
32
hooks/pre-commit
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Running pre commit hook"
|
||||||
|
|
||||||
|
## this will retrieve all of the .go files that have been
|
||||||
|
## changed since the last commit
|
||||||
|
STAGED_GO_FILES=$(git diff --cached --name-only -- '*.go')
|
||||||
|
|
||||||
|
## we can check to see if this is empty
|
||||||
|
if [[ $STAGED_GO_FILES == "" ]]; then
|
||||||
|
echo "No Go Files to Update"
|
||||||
|
else
|
||||||
|
for file in $STAGED_GO_FILES; do
|
||||||
|
## format our file
|
||||||
|
go fmt $file
|
||||||
|
## add any potential changes from our formatting to the
|
||||||
|
## commit
|
||||||
|
git add $file
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if go mod tidy -v 2>&1 | grep -q 'updates to go.mod needed'; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git diff --exit-code go.* &> /dev/null
|
||||||
|
|
||||||
|
if [ $? -eq 1 ]; then
|
||||||
|
echo "go.mod or go.sum differs, please re-add it to your commit"
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user