github.com/bazelbuild/remote-apis-sdks@v0.0.0-20240425170053-8a36686a6350/.githooks/pre-commit (about) 1 #!/bin/sh 2 3 ######################################################################## 4 # Check that all Go files have been gofmt'd. 5 ######################################################################## 6 # Find all change go files. 7 gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '\.go$') 8 9 ./check-gofmt.sh $gofiles 10 ./check-golint.sh 11 12 ######################################################################## 13 # Precommit hook to rebuild generated go code. Fails if building or 14 # copying the files fails. 15 ######################################################################## 16 bazelisk build //go/api/command:command_go_proto //go/pkg/fakes/auxpb:auxiliary_metadata_go_proto 17 GEN_CMD_PATHS=("go/api/command/command.pb.go" "go/pkg/fakes/auxpb/auxiliary_metadata.pb.go") 18 for path in "${GEN_CMD_PATHS[@]}"; do 19 echo $path "$(find $(bazelisk info bazel-bin) -path "*/${path}")" 20 cp -f "$(find $(bazelisk info bazel-bin) -path "*/${path}")" "${path}" 21 git add "${path}" 22 done