Skip to content

Commit ddeb56d

Browse files
committed
Switch from ClangFormat to Buf
1 parent a65c7a1 commit ddeb56d

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ RUN apk add --no-cache --virtual .build-deps \
1010
npm \
1111
python3-dev \
1212
&& apk add --no-cache \
13-
clang-extra-tools \
1413
libxslt \
1514
nodejs \
1615
openjdk17-jre-headless \
@@ -33,6 +32,9 @@ RUN apk add --no-cache --virtual .build-deps \
3332
svgo@3.0.3 \
3433
typescript@5.2.2 \
3534
&& apk del .build-deps \
35+
&& wget https://github.com/bufbuild/buf/releases/download/v1.32.0/buf-Linux-aarch64 -O buf \
36+
&& chmod +x buf \
37+
&& mkdir /.cache && chmod -R 777 /.cache \
3638
&& wget https://github.com/google/google-java-format/releases/download/v1.18.1/google-java-format-1.18.1-all-deps.jar -O google-java-format \
3739
&& wget https://search.maven.org/remotecontent?filepath=com/facebook/ktfmt/0.46/ktfmt-0.46-jar-with-dependencies.jar -O ktfmt \
3840
&& wget https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_amd64 -O shfmt \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This repo currently contains a single [pre-commit](https://pre-commit.com/) hook
1313
- [shfmt](https://github.com/mvdan/sh) v3.7.0 for Shell
1414
- [xsltproc](http://www.xmlsoft.org/xslt/xsltproc.html) from libxslt v10138 for XML
1515
- [terraform fmt](https://github.com/hashicorp/terraform) v1.6.3 for Terraform
16-
- [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) v16.0.6 for Protobuf
16+
- [Buf](https://github.com/bufbuild/buf) v1.32.0 for Protobuf
1717
- [SVGO](https://github.com/svg/svgo) v3.0.3 for SVG
1818
- Custom regex transformations (basically [sed](https://en.wikipedia.org/wiki/Sed)), for example:
1919
- Trimming trailing whitespace and newlines

entry.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const transformFile = (path: string, transform: (before: string) => string) =>
7474
const enum HookName {
7575
Autoflake = "autoflake",
7676
Black = "Black",
77-
ClangFormat = "ClangFormat",
77+
Buf = "Buf",
7878
GoogleJavaFormat = "google-java-format",
7979
Isort = "isort",
8080
Ktfmt = "ktfmt",
@@ -171,14 +171,9 @@ const HOOKS: Record<HookName, LockableHook> = {
171171
include: /\.py$/,
172172
runAfter: [HookName.Isort],
173173
}),
174-
[HookName.ClangFormat]: createLockableHook({
174+
[HookName.Buf]: createLockableHook({
175175
action: sources =>
176-
run(
177-
"clang-format",
178-
"-i", // Edit files in-place
179-
"--style=Google",
180-
...sources,
181-
),
176+
run("/buf", "format", "-w", ...sources.flatMap(s => ["--path", s])),
182177
include: /\.proto$/,
183178
runAfter: [HookName.Sed],
184179
}),

0 commit comments

Comments
 (0)