| From cdcf80bafba0ff61527a710899002936e2b117d6 Mon Sep 17 00:00:00 2001 | 
 | From: Lorenz Brun <lorenz@monogon.tech> | 
 | Date: Thu, 31 Aug 2023 15:52:06 +0200 | 
 | Subject: [PATCH] Add support for prepatching | 
 |  | 
 | --- | 
 |  internal/go_repository.bzl | 10 ++++++++++ | 
 |  1 file changed, 10 insertions(+) | 
 |  | 
 | diff --git a/internal/go_repository.bzl b/internal/go_repository.bzl | 
 | index cb0ac74..5a2a9e2 100644 | 
 | --- a/internal/go_repository.bzl | 
 | +++ b/internal/go_repository.bzl | 
 | @@ -257,6 +257,11 @@ def _go_repository_impl(ctx): | 
 |          if ctx.attr.debug_mode and result.stderr: | 
 |              print("fetch_repo: " + result.stderr) | 
 |   | 
 | +    # TODO(lorenz): Replace this with patch() once the patches argument no longer gets merged with | 
 | +    # the attribute pulled from ctx. | 
 | +    for p in ctx.attr.pre_patches: | 
 | +        ctx.patch(p, 1) | 
 | + | 
 |      # Repositories are fetched. Determine if build file generation is needed. | 
 |      build_file_names = ctx.attr.build_file_name.split(",") | 
 |      existing_build_file = "" | 
 | @@ -538,6 +543,11 @@ go_repository = repository_rule( | 
 |              Gazelle directives.""", | 
 |          ), | 
 |   | 
 | +        # Patches to apply before running gazelle. | 
 | +        "pre_patches": attr.label_list( | 
 | +            doc = "A list of patches to apply to the repository before gazelle runs.", | 
 | +        ), | 
 | + | 
 |          # Patches to apply after running gazelle. | 
 |          "patches": attr.label_list( | 
 |              doc = "A list of patches to apply to the repository after gazelle runs.", | 
 | --  | 
 | 2.41.0 | 
 |  |