Fix parsing VCS links starting with "git+git@" (notice "git+git://" was already supported)

This commit is contained in:
allegroai 2021-06-24 19:25:41 +03:00
parent 176b4a4cde
commit 821a0c4a2b

View File

@ -20,6 +20,15 @@ VCS_REGEX = re.compile(
r'(#(?P<fragment>\S+))?' r'(#(?P<fragment>\S+))?'
) )
VCS_EXT_REGEX = re.compile(
r'^(?P<scheme>{0})(@)'.format(r'|'.join(
[scheme.replace('+', r'\+') for scheme in ['git+git']])) +
r'((?P<login>[^/@]+)@)?'
r'(?P<path>[^#@]+)'
r'(@(?P<revision>[^#]+))?'
r'(#(?P<fragment>\S+))?'
)
# This matches just about everyting # This matches just about everyting
LOCAL_REGEX = re.compile( LOCAL_REGEX = re.compile(
r'^((?P<scheme>file)://)?' r'^((?P<scheme>file)://)?'
@ -100,7 +109,7 @@ class Requirement(object):
req = cls('-e {0}'.format(line)) req = cls('-e {0}'.format(line))
req.editable = True req.editable = True
vcs_match = VCS_REGEX.match(line) vcs_match = VCS_REGEX.match(line) or VCS_EXT_REGEX.match(line)
local_match = LOCAL_REGEX.match(line) local_match = LOCAL_REGEX.match(line)
if vcs_match is not None: if vcs_match is not None:
@ -147,7 +156,7 @@ class Requirement(object):
req = cls(line) req = cls(line)
vcs_match = VCS_REGEX.match(line) vcs_match = VCS_REGEX.match(line) or VCS_EXT_REGEX.match(line)
uri_match = URI_REGEX.match(line) uri_match = URI_REGEX.match(line)
local_match = LOCAL_REGEX.match(line) local_match = LOCAL_REGEX.match(line)
@ -226,7 +235,7 @@ class Requirement(object):
# check if the name is valid & parsed # check if the name is valid & parsed
Req.parse(name) Req.parse(name)
# if we are here, name is a valid package name, check if the vcs part is valid # if we are here, name is a valid package name, check if the vcs part is valid
if VCS_REGEX.match(uri): if VCS_REGEX.match(uri) or VCS_EXT_REGEX.match(uri):
req = cls.parse_line(uri) req = cls.parse_line(uri)
req.name = name req.name = name
return req return req