Skip to content

Commit 0aecda6

Browse files
authoredSep 22, 2020
ux: use docker to format proto files (#5384)
## Description Add a cmd to docker image and use it to format our proto files. This avoids developers the need to install clang-format Closes: #XXX
1 parent 0e311ab commit 0aecda6

File tree

7 files changed

+37
-22
lines changed

7 files changed

+37
-22
lines changed
 

‎.clang-format

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
Language: Proto
3+
BasedOnStyle: Google
4+
IndentWidth: 2
5+
ColumnLimit: 0
6+
AlignConsecutiveAssignments: true
7+
AlignConsecutiveDeclarations: true
8+
SpacesInSquareBrackets: true
9+
ReflowComments: true
10+
SortIncludes: true
11+
SortUsingDeclarations: true

‎.vscode/settings.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
"--proto_path=${workspaceRoot}/proto",
55
"--proto_path=${workspaceRoot}/third_party/proto"
66
]
7-
},
8-
"clang-format.style": "{BasedOnStyle: Google, IndentWidth: 2, ColumnLimit: 0, AlignConsecutiveAssignments: true, AlignConsecutiveDeclarations: true, SpacesInSquareBrackets: true}",
7+
}
98
}

‎Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ proto-lint:
8989
@$(DOCKER_BUF) check lint --error-format=json
9090
.PHONY: proto-lint
9191

92+
proto-format:
93+
@echo "Formatting Protobuf files"
94+
docker run -v $(shell pwd):/workspace --workdir /workspace tendermintdev/docker-build-proto find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \;
95+
.PHONY: proto-format
96+
9297
proto-check-breaking:
9398
@$(DOCKER_BUF) check breaking --against-input .git#branch=master
9499
.PHONY: proto-check-breaking

‎proto/tendermint/abci/types.proto

+10-10
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,9 @@ message TxResult {
334334

335335
// Validator
336336
message Validator {
337-
bytes address = 1; // The first 20 bytes of SHA256(public key)
337+
bytes address = 1; // The first 20 bytes of SHA256(public key)
338338
// PubKey pub_key = 2 [(gogoproto.nullable)=false];
339-
int64 power = 3; // The voting power
339+
int64 power = 3; // The voting power
340340
}
341341

342342
// ValidatorUpdate
@@ -352,19 +352,19 @@ message VoteInfo {
352352
}
353353

354354
enum EvidenceType {
355-
UNKNOWN = 0;
356-
DUPLICATE_VOTE = 1;
357-
LIGHT_CLIENT_ATTACK = 2;
355+
UNKNOWN = 0;
356+
DUPLICATE_VOTE = 1;
357+
LIGHT_CLIENT_ATTACK = 2;
358358
}
359359

360360
message Evidence {
361-
EvidenceType type = 1;
361+
EvidenceType type = 1;
362362
// The offending validator
363-
Validator validator = 2 [(gogoproto.nullable) = false];
364-
// The height when the offense occurred
365-
int64 height = 3;
363+
Validator validator = 2 [(gogoproto.nullable) = false];
364+
// The height when the offense occurred
365+
int64 height = 3;
366366
// The corresponding time where the offense occurred
367-
google.protobuf.Timestamp time = 4 [
367+
google.protobuf.Timestamp time = 4 [
368368
(gogoproto.nullable) = false,
369369
(gogoproto.stdtime) = true
370370
];

‎proto/tendermint/evidence/types.proto

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ message List {
1313
}
1414

1515
message Info {
16-
tendermint.types.Evidence evidence = 1 [(gogoproto.nullable) = false];
17-
google.protobuf.Timestamp time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
18-
repeated tendermint.types.Validator validators = 3;
16+
tendermint.types.Evidence evidence = 1 [(gogoproto.nullable) = false];
17+
google.protobuf.Timestamp time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
18+
repeated tendermint.types.Validator validators = 3;
1919
int64 total_voting_power = 4;
2020
}

‎proto/tendermint/types/evidence.proto

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ message DuplicateVoteEvidence {
1414
}
1515

1616
message LightClientAttackEvidence {
17-
LightBlock conflicting_block = 1;
18-
int64 common_height = 2;
17+
LightBlock conflicting_block = 1;
18+
int64 common_height = 2;
1919
}
2020

2121
message Evidence {
2222
oneof sum {
23-
DuplicateVoteEvidence duplicate_vote_evidence = 1;
24-
LightClientAttackEvidence light_client_attack_evidence = 2;
23+
DuplicateVoteEvidence duplicate_vote_evidence = 1;
24+
LightClientAttackEvidence light_client_attack_evidence = 2;
2525
}
2626
}
2727

‎proto/tendermint/types/types.proto

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ enum SignedMsgType {
2626
option (gogoproto.goproto_enum_stringer) = true;
2727
option (gogoproto.goproto_enum_prefix) = false;
2828

29-
SIGNED_MSG_TYPE_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "UnknownType"];
29+
SIGNED_MSG_TYPE_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "UnknownType"];
3030
// Votes
3131
SIGNED_MSG_TYPE_PREVOTE = 1 [(gogoproto.enumvalue_customname) = "PrevoteType"];
3232
SIGNED_MSG_TYPE_PRECOMMIT = 2 [(gogoproto.enumvalue_customname) = "PrecommitType"];
3333

3434
// Proposals
35-
SIGNED_MSG_TYPE_PROPOSAL = 32 [(gogoproto.enumvalue_customname) = "ProposalType"];
35+
SIGNED_MSG_TYPE_PROPOSAL = 32 [(gogoproto.enumvalue_customname) = "ProposalType"];
3636
}
3737

3838
// PartsetHeader
@@ -144,7 +144,7 @@ message SignedHeader {
144144

145145
message LightBlock {
146146
SignedHeader signed_header = 1;
147-
tendermint.types.ValidatorSet validator_set = 2;
147+
tendermint.types.ValidatorSet validator_set = 2;
148148
}
149149

150150
message BlockMeta {

0 commit comments

Comments
 (0)
Please sign in to comment.