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:
Akhil Kumar P 2020-10-27 15:34:34 +05:30 committed by GitHub
parent 6688382f2e
commit 8014fc688e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 28 deletions

View File

@ -91,7 +91,8 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
RawStringFormats:
- Delimiter: pb
- Delimiters:
- pb
Language: TextProto
BasedOnStyle: google
ReflowComments: true

View File

@ -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.

View File

@ -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:

View File

@ -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