Skip to content

Commit

Permalink
don't overwrite directives (bazel-contrib#1503)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-french authored Apr 10, 2023
1 parent a954068 commit 36b2084
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/bzlmod/go_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,22 @@ def _synthesize_gazelle_override(module, gazelle_overrides, fixups):
directives.append(directive)

if directives:
gazelle_overrides[module.path] = struct(
directives = directives,
)
_safe_append_directives(module, gazelle_overrides, directives)
fixups.extend([
buildozer_cmd("new", "go_deps.gazelle_override", module.path),
buildozer_cmd("add", "directives", name = module.path, *directives),
buildozer_cmd("rename", "name", "path", name = module.path),
])

def _safe_append_directives(module, gazelle_overrides, directives):
if module.path in gazelle_overrides:
existing = gazelle_overrides[module.path].directives
else:
existing = []
gazelle_overrides[module.path] = struct(
directives = existing + directives
)

def _get_directives(path, gazelle_overrides):
override = gazelle_overrides.get(path)
if override:
Expand Down

0 comments on commit 36b2084

Please sign in to comment.