diff --git a/tools/proto.sh b/tools/proto.sh index 7683ab68e..371ac307a 100644 --- a/tools/proto.sh +++ b/tools/proto.sh @@ -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