@@ -64,6 +64,13 @@ def _fail_on_duplicate_overrides(path, module_name, overrides):
64
64
if path in overrides :
65
65
fail ("Multiple overrides defined for Go module path \" {}\" in module \" {}\" ." .format (path , module_name ))
66
66
67
+ def _fail_on_unmatched_overrides (override_keys , resolutions , override_name ):
68
+ unmatched_overrides = [path for path in override_keys if path not in resolutions ]
69
+ if unmatched_overrides :
70
+ fail ("Some {} did not target a Go module with a matching path: {}" .format (
71
+ override_name , ", " .join (unmatched_overrides )
72
+ ))
73
+
67
74
def _check_directive (directive ):
68
75
if directive .startswith ("gazelle:" ) and " " in directive and not directive [len ("gazelle:" ):][0 ].isspace ():
69
76
return
@@ -313,13 +320,9 @@ def _go_deps_impl(module_ctx):
313
320
raw_version = raw_version ,
314
321
)
315
322
316
- unmatched_gazelle_overrides = []
317
- for path in gazelle_overrides .keys ():
318
- if path not in module_resolutions :
319
- unmatched_gazelle_overrides .append (path )
320
- if unmatched_gazelle_overrides :
321
- fail ("Some gazelle_overrides did not target a Go module with a matching path: {}"
322
- .format (", " .join (unmatched_gazelle_overrides )))
323
+ _fail_on_unmatched_overrides (archive_overrides .keys (), module_resolutions , "archive_overrides" )
324
+ _fail_on_unmatched_overrides (gazelle_overrides .keys (), module_resolutions , "gazelle_overrides" )
325
+ _fail_on_unmatched_overrides (module_overrides .keys (), module_resolutions , "module_overrides" )
323
326
324
327
# All `replace` directives are applied after version resolution.
325
328
# We can simply do this by checking the replace paths' existence
0 commit comments