fix(tools): compare protos against an export of main so the gate runs as any user

This commit is contained in:
sam committed 2026-10-24 17:27:34 +11:00
1 parent 8ccac46fc9
commit 7973feceb0
1 file changed
+7 -1
+7 -1
View File
@@ -19,7 +19,13 @@ case "${1:-}" in
# has no published contract to compare. Tags in CI also need this ref.
git rev-parse --verify refs/heads/main >/dev/null
if git cat-file -e main:proto/buf.yaml 2>/dev/null; then
buf breaking proto --against "$(git rev-parse --git-common-dir)#branch=main,subdir=proto"
# Compare against an export of main, not the git dir: buf clones a git
# input, which git refuses when the checkout's owner differs from the
# runner's (a task container's gate runs as root).
baseline=$(mktemp -d)
trap 'rm -rf "$baseline"' EXIT
git archive main proto | tar -x -C "$baseline"
buf breaking proto --against "$baseline/proto"
else
echo 'No proto baseline on main yet; checking the first contract with buf lint.'
fi