Fixed wrong regular expression for vcs requirements

The regular expression to parse requirement line is also used for
constrains files. However, it will not match those lines which
point to VCS, such as git+http or git+https which pypi accept.

This commit fixes the issue.

Despite that we only need to change the RE to
^(?P<url>\s*(?:-e\s)?\s*(?:(?:git\+)?(?:https|http)|file)://[^#]*)#
egg=(?P<name>[-\.\w]+)
to fix the issue for git+http and git+https, pypi accepts more VCS
URI schemes other than git. This patch also looses the match for
these cases to be accepted.

Change-Id: I202078f5ca4ba6da4ab0ed52d97d41997674c1b4
This commit is contained in:
Zhongcheng Lao 2017-05-20 20:01:43 -07:00
parent 7cede8e4db
commit f562496f7d
2 changed files with 15 additions and 2 deletions

View File

@ -82,7 +82,7 @@ Requirements = collections.namedtuple('Requirements', ['reqs'])
url_re = re.compile(
'^(?P<url>\s*(?:-e\s)?\s*(?:(?:git+)?https|http|file)://[^#]*)'
'^(?P<url>\s*(?:-e\s)?\s*(?:(?:[a-z]+\+)?(?:[a-z]+))://[^#]*)'
'#egg=(?P<name>[-\.\w]+)')

View File

@ -75,7 +75,20 @@ class TestParseRequirement(testtools.TestCase):
line='-e file:///path/to/bar#egg=bar',
req=requirement.Requirement('bar', '-e file:///path/to/bar', '', '',
''),
permit_urls=True))]
permit_urls=True)),
('editable_vcs_git', dict(
line='-e git+http://github.com/path/to/oslo.bar#egg=oslo.bar',
req=requirement.Requirement('oslo.bar',
'-e git+http://github.com'
'/path/to/oslo.bar', '', '', ''),
permit_urls=True)),
('editable_vcs_git_ssh', dict(
line='-e git+ssh://github.com/path/to/oslo.bar#egg=oslo.bar',
req=requirement.Requirement('oslo.bar',
'-e git+ssh://github.com'
'/path/to/oslo.bar', '', '', ''),
permit_urls=True)),
]
scenarios = dist_scenarios + url_scenarios
def test_parse(self):