summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-08-24 17:08:40 +0000
committerGerrit Code Review <review@openstack.org>2018-08-24 17:08:40 +0000
commit589871fddb83b603569f2c376198b86d11ec36d9 (patch)
treea39b6587257f82ed9fdf16e4c6eee55da2bb9610
parent8ab5416db7349aedb6276bddcf8c36afa92444c0 (diff)
parentbca35333bcc1102040158ca97f2aac3bd932430b (diff)
downloadpbr-589871fddb83b603569f2c376198b86d11ec36d9.tar.gz
Merge "Support subdirectory in the url"
-rw-r--r--pbr/packaging.py6
-rw-r--r--pbr/tests/test_packaging.py11
2 files changed, 13 insertions, 4 deletions
diff --git a/pbr/packaging.py b/pbr/packaging.py
index 8656a6c..bb0ec6b 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -137,13 +137,15 @@ def parse_requirements(requirements_files=None, strip_markers=False):
# such as:
# -e git://github.com/openstack/nova/master#egg=nova
# -e git://github.com/openstack/nova/master#egg=nova-1.2.3
+ # -e git+https://foo.com/zipball#egg=bar&subdirectory=baz
if re.match(r'\s*-e\s+', line):
- line = re.sub(r'\s*-e\s+.*#egg=(.*)$', egg_fragment, line)
+ line = re.sub(r'\s*-e\s+.*#egg=([^&]+).*$', egg_fragment, line)
# such as:
# http://github.com/openstack/nova/zipball/master#egg=nova
# http://github.com/openstack/nova/zipball/master#egg=nova-1.2.3
+ # git+https://foo.com/zipball#egg=bar&subdirectory=baz
elif re.match(r'\s*(https?|git(\+(https|ssh))?):', line):
- line = re.sub(r'\s*(https?|git(\+(https|ssh))?):.*#egg=(.*)$',
+ line = re.sub(r'\s*(https?|git(\+(https|ssh))?):.*#egg=([^&]+).*$',
egg_fragment, line)
# -f lines are for index locations, and don't get used here
elif re.match(r'\s*-f\s+', line):
diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py
index 5512d5d..9bd91ae 100644
--- a/pbr/tests/test_packaging.py
+++ b/pbr/tests/test_packaging.py
@@ -579,6 +579,11 @@ class ParseRequirementsTestScenarios(base.BaseTestCase):
('versioned', {'versioned': True, 'expected': ['bar>=1.2.3']})
]
+ subdirectory_scenarios = [
+ ('non-subdirectory', {'has_subdirectory': False}),
+ ('has-subdirectory', {'has_subdirectory': True})
+ ]
+
scenarios = [
('normal', {'url': "foo\nbar", 'expected': ['foo', 'bar']}),
('normal_with_comments', {
@@ -591,7 +596,7 @@ class ParseRequirementsTestScenarios(base.BaseTestCase):
('ssh_egg_url', {'url': 'git+ssh://foo.com/zipball#egg=bar'}),
('git_https_egg_url', {'url': 'git+https://foo.com/zipball#egg=bar'}),
('http_egg_url', {'url': 'https://foo.com/zipball#egg=bar'}),
- ], versioned_scenarios)
+ ], versioned_scenarios, subdirectory_scenarios)
scenarios = scenarios + testscenarios.multiply_scenarios(
[
@@ -601,7 +606,7 @@ class ParseRequirementsTestScenarios(base.BaseTestCase):
('non-editable', {'editable': False}),
('editable', {'editable': True}),
],
- versioned_scenarios)
+ versioned_scenarios, subdirectory_scenarios)
def test_parse_requirements(self):
tmp_file = tempfile.NamedTemporaryFile()
@@ -610,6 +615,8 @@ class ParseRequirementsTestScenarios(base.BaseTestCase):
req_string = ("-e %s" % req_string)
if hasattr(self, 'versioned') and self.versioned:
req_string = ("%s-1.2.3" % req_string)
+ if hasattr(self, 'has_subdirectory') and self.has_subdirectory:
+ req_string = ("%s&subdirectory=baz" % req_string)
with open(tmp_file.name, 'w') as fh:
fh.write(req_string)
self.assertEqual(self.expected,