Skip to content

Commit b6c5ed5

Browse files
authored
Rename files, fix path exclusion with pathsep (#229)
1 parent 78ade87 commit b6c5ed5

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

src/common/argsupport.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,8 @@ def get_all_packages(repository_root_path, packages_str,
5151
repository_root_path, p, generation_stategy_factory, verbose)
5252
for package in packages:
5353
for exclusion_path in exclusion_paths:
54-
prefix_match = True
55-
if exclusion_path.endswith("/"):
56-
exclusion_path = exclusion_path[:-1]
57-
prefix_match = False
5854
if package.startswith(exclusion_path):
59-
if prefix_match or package.endswith(exclusion_path):
60-
break
55+
break
6156
else:
6257
if package not in all_packages:
6358
all_packages.add(package)
@@ -69,7 +64,7 @@ def get_all_packages(repository_root_path, packages_str,
6964
def _find_packages_with_md(repository_root_path, target_pattern, fac, verbose):
7065
"""
7166
Returns all packages in the specified target pattern, as a list of strings,
72-
that are "maven aware" packages.
67+
that are "manifest aware" packages.
7368
"""
7469
path = os.path.join(repository_root_path, _target_pattern_to_path(target_pattern))
7570

src/common/buildpomupdate.py renamed to src/common/metadataupdate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
77
8-
This module is responsible for updating BUILD.pom and BUILD.pom.released files.
8+
This module is responsible for updating metadata files, such as BUILD.pom and
9+
BUILD.pom.released
910
"""
1011

1112

src/update.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
from common import argsupport
1212
from common import common
13+
from common import manifestcontent as manifestcontent
14+
from common import metadataupdate
1315
from common import version_increment_strategy as vis
1416
from config import config
15-
from common import manifestcontent as manifestcontent
1617
from generate import generationstrategyfactory
17-
from common import buildpomupdate
1818
import argparse
1919
import sys
2020

@@ -50,6 +50,8 @@ def _parse_arguments(args):
5050
help="Adds or updates the value of 'generation_mode' manifest files")
5151
parser.add_argument("--add_missing_generation_mode", required=False, action='store_true',
5252
help="Adds 'generation_mode' to manifest files")
53+
parser.add_argument("--verbose", required=False, action="store_true",
54+
help="Verbose output")
5355

5456
parser.add_argument("--repo_root", type=str, required=False,
5557
help="the root of the repository")
@@ -61,8 +63,8 @@ def _parse_arguments(args):
6163
repo_root = common.get_repo_root(args.repo_root)
6264
cfg = config.load(repo_root)
6365
fac = generationstrategyfactory.GenerationStrategyFactory(
64-
repo_root, cfg, manifestcontent.NOOP, verbose=False)
65-
packages = argsupport.get_all_packages(repo_root, args.package, fac)
66+
repo_root, cfg, manifestcontent.NOOP, verbose=args.verbose)
67+
packages = argsupport.get_all_packages(repo_root, args.package, fac, verbose=args.verbose)
6668
assert len(packages) > 0, "Did not find any packages at [%s]" % args.package
6769

6870
if (args.new_version is not None or
@@ -74,7 +76,7 @@ def _parse_arguments(args):
7476
args.new_generation_mode is not None or
7577
args.add_missing_generation_mode):
7678

77-
buildpomupdate.update_build_pom_file(
79+
metadataupdate.update_build_pom_file(
7880
repo_root, packages, fac,
7981
args.new_version,
8082
args.update_version_using_version_increment_strategy,
@@ -88,7 +90,7 @@ def _parse_arguments(args):
8890
if (args.new_released_version is not None or
8991
args.new_released_artifact_hash is not None or
9092
args.update_released_artifact_hash_to_current):
91-
buildpomupdate.update_released_artifact(
93+
metadataupdate.update_released_artifact(
9294
repo_root, packages, fac,
9395
cfg.all_src_exclusions,
9496
args.new_released_version,

tests/common/argsupporttest.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
ZK_CONNECT_PACKAGES = ["projects/libs/servicelibs/zk-connect",]
2121

2222
GRAIL_PACKAGES = ["projects/libs/servicelibs/grail/grail-admin-api",
23-
"projects/libs/servicelibs/grail/grail-admin-impl",]
23+
"projects/libs/servicelibs/grail/grail-admin-impl",
24+
"projects/libs/servicelibs/grailer/jones"]
2425

2526
ALL_PACKAGES = PASTRY_PACKAGES + ZK_CONNECT_PACKAGES + GRAIL_PACKAGES
2627

@@ -119,18 +120,20 @@ def test_get_all_packages__multiple_packages__multiple_exclusions(self):
119120
self.assertIn("projects/libs/pastry/pastry-metrics", packages)
120121
self.assertNotIn("projects/libs/servicelibs/grail/grail-admin-api", packages)
121122
self.assertNotIn("projects/libs/servicelibs/grail/grail-admin-impl", packages)
123+
self.assertNotIn("projects/libs/servicelibs/grailer/jones", packages)
122124
self.assertNotIn("projects/libs/servicelibs/zk-connect", packages)
123125

124-
def test_exact_match_exclusions(self):
125-
packages_str = "projects/libs,-projects/libs/servicelibs/zk,-projects/libs/servicelibs/grail/grail-admin-api/, -projects/libs/servicelibs/grail/"
126+
def test_exclusion_includes_pathsep(self):
127+
packages_str = "projects/libs,-projects/libs/servicelibs/zk, -projects/libs/servicelibs/grail/"
126128

127129
packages = argsupport.get_all_packages(
128130
self.repo_root, packages_str, self.fac)
129131

130132
self.assertIn("projects/libs/pastry/abstractions", packages)
131133
self.assertIn("projects/libs/pastry/pastry-metrics", packages)
134+
self.assertIn("projects/libs/servicelibs/grailer/jones", packages)
132135
self.assertNotIn("projects/libs/servicelibs/grail/grail-admin-api", packages)
133-
self.assertIn("projects/libs/servicelibs/grail/grail-admin-impl", packages)
136+
self.assertNotIn("projects/libs/servicelibs/grail/grail-admin-impl", packages)
134137
self.assertNotIn("projects/libs/servicelibs/zk-connect", packages)
135138

136139
def test_target_pattern_to_path(self):

tests/common/buildpomupdatetest.py renamed to tests/common/metadataupdatetest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77

88

9-
import common.buildpomupdate as buildpomupdate
9+
import common.metadataupdate as buildpomupdate
1010
import common.os_util as os_util
1111
import config.config as config
1212
import config.exclusions as exclusions

0 commit comments

Comments
 (0)