Skip to content

Commit

Permalink
Fix package spec handling for the wildcard pattern //...
Browse files Browse the repository at this point in the history
This pattern requires special-casing as the usual rule of packages having a trailing slash, both in the pattern and when constructing the prefix to match against, does not hold.

PiperOrigin-RevId: 446187953
(cherry picked from commit 8c1a053)
  • Loading branch information
Googler authored and keith committed Jul 7, 2022
1 parent 4e8b6ae commit f805ee0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions swift/internal/package_specs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def _parse_package_spec(*, package_spec, workspace_name):
fail(("A package list may only contain absolute labels " +
"(found '{}').").format(package_spec))

if package_spec.endswith("/..."):
if package_spec == "...":
match_subpackages = True
package = ""
elif package_spec.endswith("/..."):
match_subpackages = True
package = package_spec[:-4]
else:
Expand Down Expand Up @@ -124,11 +127,13 @@ def _label_matches_package_spec_ignoring_exclusion(*, label, package_spec):
workspace_name = label.workspace_name

if package_spec.match_subpackages:
if workspace_name != package_spec.workspace_name:
return False
if not package_spec.package:
return True
return (
workspace_name == package_spec.workspace_name and (
package == package_spec.package or
package.startswith(package_spec.package + "/")
)
package == package_spec.package or
package.startswith(package_spec.package + "/")
)
else:
return (
Expand Down

0 comments on commit f805ee0

Please sign in to comment.