diff --git a/Dockerfile b/Dockerfile index 90466d4..f35becb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,6 @@ RUN apk add --no-cache --virtual .build-deps \ npm \ python3-dev \ && apk add --no-cache \ - clang-extra-tools \ libxslt \ nodejs \ openjdk17-jre-headless \ @@ -33,6 +32,9 @@ RUN apk add --no-cache --virtual .build-deps \ svgo@3.0.3 \ typescript@5.2.2 \ && apk del .build-deps \ + && wget https://github.com/bufbuild/buf/releases/download/v1.32.0/buf-Linux-aarch64 -O buf \ + && chmod +x buf \ + && mkdir /.cache && chmod -R 777 /.cache \ && 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 \ && wget https://search.maven.org/remotecontent?filepath=com/facebook/ktfmt/0.46/ktfmt-0.46-jar-with-dependencies.jar -O ktfmt \ && wget https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_amd64 -O shfmt \ diff --git a/README.md b/README.md index 9f8c239..bdc5943 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This repo currently contains a single [pre-commit](https://pre-commit.com/) hook - [shfmt](https://github.com/mvdan/sh) v3.7.0 for Shell - [xsltproc](http://www.xmlsoft.org/xslt/xsltproc.html) from libxslt v10138 for XML - [terraform fmt](https://github.com/hashicorp/terraform) v1.6.3 for Terraform -- [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) v16.0.6 for Protobuf +- [Buf](https://github.com/bufbuild/buf) v1.32.0 for Protobuf - [SVGO](https://github.com/svg/svgo) v3.0.3 for SVG - Custom regex transformations (basically [sed](https://en.wikipedia.org/wiki/Sed)), for example: - Trimming trailing whitespace and newlines diff --git a/entry.ts b/entry.ts index 26e0ec5..c50e526 100644 --- a/entry.ts +++ b/entry.ts @@ -74,7 +74,7 @@ const transformFile = (path: string, transform: (before: string) => string) => const enum HookName { Autoflake = "autoflake", Black = "Black", - ClangFormat = "ClangFormat", + Buf = "Buf", GoogleJavaFormat = "google-java-format", Isort = "isort", Ktfmt = "ktfmt", @@ -171,14 +171,9 @@ const HOOKS: Record = { include: /\.py$/, runAfter: [HookName.Isort], }), - [HookName.ClangFormat]: createLockableHook({ + [HookName.Buf]: createLockableHook({ action: sources => - run( - "clang-format", - "-i", // Edit files in-place - "--style=Google", - ...sources, - ), + run("/buf", "format", "-w", ...sources.flatMap(s => ["--path", s])), include: /\.proto$/, runAfter: [HookName.Sed], }),