Skip to content

Commit 8014fc6

Browse files
akhilkumarpilliAlessio Tregliatac0turtle
authored
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>
1 parent 6688382 commit 8014fc6

File tree

4 files changed

+8
-28
lines changed

4 files changed

+8
-28
lines changed

.clang-format

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ PenaltyExcessCharacter: 1000000
9191
PenaltyReturnTypeOnItsOwnLine: 60
9292
PointerAlignment: Right
9393
RawStringFormats:
94-
- Delimiter: pb
94+
- Delimiters:
95+
- pb
9596
Language: TextProto
9697
BasedOnStyle: google
9798
ReflowComments: true

CONTRIBUTING.md

+2
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ build, in which case we can fall back on `go mod tidy -v`.
142142

143143
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.
144144

145+
For formatting code in `.proto` files, you can run `make proto-format` command.
146+
145147
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`.
146148

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

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,11 @@ proto-gen:
362362
@./scripts/protocgen.sh
363363

364364
proto-format:
365+
@echo "Formatting Protobuf files"
366+
docker run -v $(shell pwd):/workspace \
367+
--workdir /workspace tendermintdev/docker-build-proto \
365368
find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \;
369+
.PHONY: proto-format
366370

367371
# This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed
368372
proto-gen-any:

contrib/devtools/proto-tools-installer.sh

-27
Original file line numberDiff line numberDiff line change
@@ -119,37 +119,10 @@ f_install_protoc_gen_swagger() {
119119
f_print_done
120120
}
121121

122-
f_install_clang_format() {
123-
f_print_installing_with_padding clang-format
124-
125-
if which clang-format &>/dev/null ; then
126-
echo -e "\talready installed. Skipping."
127-
return 0
128-
fi
129-
130-
case "${UNAME_S}" in
131-
Linux)
132-
if [ -e /etc/debian_version ]; then
133-
echo -e "\tRun: sudo apt-get install clang-format" >&2
134-
elif [ -e /etc/fedora-release ]; then
135-
echo -e "\tRun: sudo dnf install clang" >&2
136-
else
137-
echo -e "\tRun (as root): subscription-manager repos --enable rhel-7-server-devtools-rpms ; yum install llvm-toolset-7" >&2
138-
fi
139-
;;
140-
Darwin)
141-
echo "\tRun: brew install clang-format" >&2
142-
;;
143-
*)
144-
echo "\tunknown operating system. Skipping." >&2
145-
esac
146-
}
147-
148122
f_ensure_tools
149123
f_ensure_dirs
150124
f_install_protoc
151125
f_install_buf
152126
f_install_protoc_gen_gocosmos
153127
f_install_protoc_gen_grpc_gateway
154128
f_install_protoc_gen_swagger
155-
f_install_clang_format

0 commit comments

Comments
 (0)