Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support exact match syntax for package exclusions #179

Merged
merged 1 commit into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion common/argsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ def get_all_packages(repository_root_path, packages_str, verbose=False):
packages = bazel.query_all_artifact_packages(repository_root_path, p, verbose)
for package in packages:
for exclusion_path in exclusion_paths:
prefix_match = True
if exclusion_path.endswith("/"):
exclusion_path = exclusion_path[:-1]
prefix_match = False
if package.startswith(exclusion_path):
break
if prefix_match or package.endswith(exclusion_path):
break
else:
if not package in all_packages:
all_packages.add(package)
Expand Down
21 changes: 19 additions & 2 deletions tests/argsupporttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
from crawl import bazel
import unittest


PASTRY_PACKAGES = ["projects/libs/pastry/abstractions",
"projects/libs/pastry/pastry-metrics",]
"projects/libs/pastry/pastry-metrics",]


ZK_CONNECT_PACKAGES = ["projects/libs/servicelibs/zk-connect",]


GRAIL_PACKAGES = ["projects/libs/servicelibs/grail/grail-admin-api",
"projects/libs/servicelibs/grail/grail-admin-impl",]


ALL_PACKAGES_DICT = {"projects/libs" : PASTRY_PACKAGES + ZK_CONNECT_PACKAGES + GRAIL_PACKAGES,
"projects/libs/servicelibs" : ZK_CONNECT_PACKAGES + GRAIL_PACKAGES,
"projects/libs/pastry" : PASTRY_PACKAGES,
Expand Down Expand Up @@ -108,6 +112,19 @@ def test_get_all_packages__multiple_packages__multiple_exclusions(self):
self.assertNotIn("projects/libs/servicelibs/grail/grail-admin-api", packages)
self.assertNotIn("projects/libs/servicelibs/grail/grail-admin-impl", packages)
self.assertNotIn("projects/libs/servicelibs/zk-connect", packages)



def test_exact_match_exclusions(self):
packages_str = "projects/libs,-projects/libs/servicelibs/zk,-projects/libs/servicelibs/grail/grail-admin-api/, -projects/libs/servicelibs/grail/"

packages = argsupport.get_all_packages("root", packages_str)

self.assertIn("projects/libs/pastry/abstractions", packages)
self.assertIn("projects/libs/pastry/pastry-metrics", packages)
self.assertNotIn("projects/libs/servicelibs/grail/grail-admin-api", packages)
self.assertIn("projects/libs/servicelibs/grail/grail-admin-impl", packages)
self.assertNotIn("projects/libs/servicelibs/zk-connect", packages)


if __name__ == '__main__':
unittest.main()
Loading