From a75e9e0db3ee94531cd21a49c39e46eb7706dc5c Mon Sep 17 00:00:00 2001 From: David Fluck Date: Tue, 8 Oct 2024 17:14:45 -0400 Subject: [PATCH] * Add pre-commit step to replace lock-api-state.sh, which ensures that there are no buf image changes to commit. This was formerly run by rph at the beginning of a release. --- .pre-commit-config.yaml | 5 +++++ pre-commit/lock-api-state.sh | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100755 pre-commit/lock-api-state.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bcc2a6288662..7d9ba7d8ed98 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -72,6 +72,11 @@ repos: description: "Runs `golangci-lint`, install https://github.com/golangci/golangci-lint" exclude: ^(proto/pkg|hpc-ard-launcher-go/launcher/) require_serial: true + - id: lock-api-state + name: "Generate buf image (lock-api-state.sh)" + entry: ./pre-commit/lock-api-state.sh + language: "script" + description: "Attempts to generate a new buf.image.bin, and fails if there are changes to commit." - repo: https://github.com/adrienverge/yamllint.git rev: v1.28.0 diff --git a/pre-commit/lock-api-state.sh b/pre-commit/lock-api-state.sh new file mode 100755 index 000000000000..a526c0069ba2 --- /dev/null +++ b/pre-commit/lock-api-state.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Regenerate proto/buf.image.bin +make -C proto gen-buf-image + +# If proto/buf.image.bin has been modified locally, then we have changes to +# commit, and the status check returns a 1 and fails. Otherwise, it returns a 0 +# and succeeds. +git diff --exit-code -- proto/buf.image.bin +exit $?