From 8014fc688e40ad82ff5d6b1898c50d5ee7a8a592 Mon Sep 17 00:00:00 2001 From: Akhil Kumar P <36399231+akhilkumarpilli@users.noreply.github.com> Date: Tue, 27 Oct 2020 15:34:34 +0530 Subject: [PATCH] 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 Co-authored-by: Marko --- .clang-format | 3 ++- CONTRIBUTING.md | 2 ++ Makefile | 4 ++++ contrib/devtools/proto-tools-installer.sh | 27 ----------------------- 4 files changed, 8 insertions(+), 28 deletions(-) diff --git a/.clang-format b/.clang-format index dec78f0f7..7f662a4fd 100644 --- a/.clang-format +++ b/.clang-format @@ -91,7 +91,8 @@ PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Right RawStringFormats: - - Delimiter: pb + - Delimiters: + - pb Language: TextProto BasedOnStyle: google ReflowComments: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 35e4705c0..e13dba1b8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. diff --git a/Makefile b/Makefile index b9f0beebc..dd21bbf2d 100644 --- a/Makefile +++ b/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: diff --git a/contrib/devtools/proto-tools-installer.sh b/contrib/devtools/proto-tools-installer.sh index fd287ddd8..f8bd2f621 100755 --- a/contrib/devtools/proto-tools-installer.sh +++ b/contrib/devtools/proto-tools-installer.sh @@ -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