Fix clang-format to specific version (#7350)
* Update clang-format install script * Address PR comments * Update clang-format install command * Format makefile * Use docker for formatting proto * Comment out delimiter config * Update contributing.md and .clang-format Co-authored-by: Alessio Treglia <alessio@tendermint.com> Co-authored-by: Marko <marbar3778@yahoo.com>
This commit is contained in:
parent
6688382f2e
commit
8014fc688e
|
@ -91,7 +91,8 @@ PenaltyExcessCharacter: 1000000
|
|||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Right
|
||||
RawStringFormats:
|
||||
- Delimiter: pb
|
||||
- Delimiters:
|
||||
- pb
|
||||
Language: TextProto
|
||||
BasedOnStyle: google
|
||||
ReflowComments: true
|
||||
|
|
|
@ -142,6 +142,8 @@ build, in which case we can fall back on `go mod tidy -v`.
|
|||
|
||||
We use [Protocol Buffers](https://developers.google.com/protocol-buffers) along with [gogoproto](https://github.com/gogo/protobuf) to generate code for use in Cosmos-SDK.
|
||||
|
||||
For formatting code in `.proto` files, you can run `make proto-format` command.
|
||||
|
||||
For linting and checking breaking changes, we use [buf](https://buf.build/). There are two options for linting and to check if your changes will cause a break. The first is that you can install [buf](https://buf.build/docs/installation) locally, the commands for running buf after installing are `make proto-lint` and the breaking changes check will be `make proto-check-breaking`. If you do not want to install buf and have docker installed already then you can use these commands `make proto-lint-docker` and `make proto-check-breaking-docker`.
|
||||
|
||||
To generate the protobuf stubs you must have `protoc` and `protoc-gen-gocosmos` installed. To install these tools run `make proto-tools`. After this step you will be able to run `make proto-gen` to generate the protobuf stubs.
|
||||
|
|
4
Makefile
4
Makefile
|
@ -362,7 +362,11 @@ proto-gen:
|
|||
@./scripts/protocgen.sh
|
||||
|
||||
proto-format:
|
||||
@echo "Formatting Protobuf files"
|
||||
docker run -v $(shell pwd):/workspace \
|
||||
--workdir /workspace tendermintdev/docker-build-proto \
|
||||
find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \;
|
||||
.PHONY: proto-format
|
||||
|
||||
# This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed
|
||||
proto-gen-any:
|
||||
|
|
|
@ -119,32 +119,6 @@ f_install_protoc_gen_swagger() {
|
|||
f_print_done
|
||||
}
|
||||
|
||||
f_install_clang_format() {
|
||||
f_print_installing_with_padding clang-format
|
||||
|
||||
if which clang-format &>/dev/null ; then
|
||||
echo -e "\talready installed. Skipping."
|
||||
return 0
|
||||
fi
|
||||
|
||||
case "${UNAME_S}" in
|
||||
Linux)
|
||||
if [ -e /etc/debian_version ]; then
|
||||
echo -e "\tRun: sudo apt-get install clang-format" >&2
|
||||
elif [ -e /etc/fedora-release ]; then
|
||||
echo -e "\tRun: sudo dnf install clang" >&2
|
||||
else
|
||||
echo -e "\tRun (as root): subscription-manager repos --enable rhel-7-server-devtools-rpms ; yum install llvm-toolset-7" >&2
|
||||
fi
|
||||
;;
|
||||
Darwin)
|
||||
echo "\tRun: brew install clang-format" >&2
|
||||
;;
|
||||
*)
|
||||
echo "\tunknown operating system. Skipping." >&2
|
||||
esac
|
||||
}
|
||||
|
||||
f_ensure_tools
|
||||
f_ensure_dirs
|
||||
f_install_protoc
|
||||
|
@ -152,4 +126,3 @@ f_install_buf
|
|||
f_install_protoc_gen_gocosmos
|
||||
f_install_protoc_gen_grpc_gateway
|
||||
f_install_protoc_gen_swagger
|
||||
f_install_clang_format
|
||||
|
|
Loading…
Reference in New Issue