From a2250d999fb4457a70c1cd4fe58737619f0f8f82 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Mon, 6 Nov 2023 10:21:34 -0800 Subject: [PATCH] chore: add a pre-commit hook config (#774) This matches the Bazel recommendation from https://github.com/bazel-contrib/rules-template for configuring an optional, client-side automation for formatting BUILD/bzl files before sending a PR. It has been found to save a bunch of time for contributors who otherwise trip over the server-side CI check and have to do an extra iteration to get their PR green. I imagine Googlers are already relying on some Piper feature to do the equivalent when they work on this code, so they haven't noticed the deficiency. --- .pre-commit-config.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..52c7cd0 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,12 @@ +# Optional local setup for a git pre-commit hook to automatically format/lint. +# This avoids sending a red PR and having to find the buildifier output on the CI results page. +# See https://pre-commit.com for more information on installing pre-commit. +# See https://pre-commit.com/hooks.html for more hooks. + +repos: + # Check formatting and lint for starlark code + - repo: https://github.com/keith/pre-commit-buildifier + rev: 6.3.3 + hooks: + - id: buildifier + - id: buildifier-lint