From 78153cf9cdd7d9f06cf15fb4c79377426ac813c1 Mon Sep 17 00:00:00 2001 From: Morten Mjelva Date: Sun, 15 Feb 2026 10:14:02 +0100 Subject: [PATCH] fix: Conditionally mark buf_download_releases as reproducible --- buf/internal/toolchain.bzl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/buf/internal/toolchain.bzl b/buf/internal/toolchain.bzl index 15e691c..634316f 100644 --- a/buf/internal/toolchain.bzl +++ b/buf/internal/toolchain.bzl @@ -178,7 +178,17 @@ def _buf_download_releases_impl(ctx): ), ) attrs = {"version": version, "repository_url": repository_url, "sha256": sha256} - return update_attrs(ctx.attr, attrs.keys(), attrs) + updated_attrs = update_attrs(ctx.attr, attrs.keys(), attrs) + + # Bazel <8.3.0 lacks ctx.repo_metadata + if not hasattr(ctx, "repo_metadata"): + return updated_attrs + + reproducible = ctx.attr.sha256 != "" + return ctx.repo_metadata( + reproducible = reproducible, + attrs_for_reproducibility = {} if reproducible else updated_attrs, + ) buf_download_releases = repository_rule( implementation = _buf_download_releases_impl,