Commit 275d09f9 by finswimmer Committed by Sébastien Eustace

fix (git.py): git url's can now contain longer path names, e.g. projects like in gitlab (#1756)

parent dbe2c380
...@@ -9,24 +9,24 @@ from poetry.utils._compat import decode ...@@ -9,24 +9,24 @@ from poetry.utils._compat import decode
PATTERNS = [ PATTERNS = [
re.compile( re.compile(
r"^(git\+)?"
r"(?P<protocol>https?|git|ssh|rsync|file)://"
r"(?:(?P<user>.+)@)*"
r"(?P<resource>[a-z0-9_.-]*)"
r"(:?P<port>[\d]+)?"
r"(?P<pathname>[:/]((?P<owner>[\w\-]+)/)?"
r"((?P<name>[\w\-.]+?)(\.git|/)?)?)"
r"([@#](?P<rev>[^@#]+))?"
r"$"
),
re.compile(
r"(git\+)?" r"(git\+)?"
r"((?P<protocol>\w+)://)" r"((?P<protocol>\w+)://)"
r"((?P<user>\w+)@)?" r"((?P<user>\w+)@)?"
r"(?P<resource>[\w.\-]+)" r"(?P<resource>[\w.\-]+)"
r"(:(?P<port>\d+))?" r"(:(?P<port>\d+))?"
r"(?P<pathname>(/(?P<owner>\w+)/)" r"(?P<pathname>(/(?P<owner>\w+)/)"
r"(/?(?P<name>[\w\-]+)(\.git|/)?)?)" r"((?P<projects>([\w\-/]+)/)?(?P<name>[\w\-]+)(\.git|/)?)?)"
r"([@#](?P<rev>[^@#]+))?"
r"$"
),
re.compile(
r"^(git\+)?"
r"(?P<protocol>https?|git|ssh|rsync|file)://"
r"(?:(?P<user>.+)@)*"
r"(?P<resource>[a-z0-9_.-]*)"
r"(:?P<port>[\d]+)?"
r"(?P<pathname>[:/]((?P<owner>[\w\-]+)/(?P<projects>([\w\-/]+)/)?)?"
r"((?P<name>[\w\-.]+?)(\.git|/)?)?)"
r"([@#](?P<rev>[^@#]+))?" r"([@#](?P<rev>[^@#]+))?"
r"$" r"$"
), ),
...@@ -34,7 +34,7 @@ PATTERNS = [ ...@@ -34,7 +34,7 @@ PATTERNS = [
r"^(?:(?P<user>.+)@)*" r"^(?:(?P<user>.+)@)*"
r"(?P<resource>[a-z0-9_.-]*)[:]*" r"(?P<resource>[a-z0-9_.-]*)[:]*"
r"(?P<port>[\d]+)?" r"(?P<port>[\d]+)?"
r"(?P<pathname>/?(?P<owner>.+)/(?P<name>.+).git)" r"(?P<pathname>/?(?P<owner>.+)/(?P<projects>([\w\-/]+)/)?(?P<name>.+).git)"
r"([@#](?P<rev>[^@#]+))?" r"([@#](?P<rev>[^@#]+))?"
r"$" r"$"
), ),
...@@ -43,6 +43,7 @@ PATTERNS = [ ...@@ -43,6 +43,7 @@ PATTERNS = [
r"(?P<resource>[\w.\-]+)" r"(?P<resource>[\w.\-]+)"
r"[:/]{1,2}" r"[:/]{1,2}"
r"(?P<pathname>((?P<owner>\w+)/)?" r"(?P<pathname>((?P<owner>\w+)/)?"
r"(?P<projects>([\w\-/]+)/)?"
r"((?P<name>[\w\-]+)(\.git|/)?)?)" r"((?P<name>[\w\-]+)(\.git|/)?)?)"
r"([@#](?P<rev>[^@#]+))?" r"([@#](?P<rev>[^@#]+))?"
r"$" r"$"
......
...@@ -62,6 +62,14 @@ from poetry.vcs.git import GitUrl ...@@ -62,6 +62,14 @@ from poetry.vcs.git import GitUrl
"git+file://C:\\Users\\hello\\testing.git#zkat/windows-files", "git+file://C:\\Users\\hello\\testing.git#zkat/windows-files",
GitUrl("file://C:\\Users\\hello\\testing.git", "zkat/windows-files"), GitUrl("file://C:\\Users\\hello\\testing.git", "zkat/windows-files"),
), ),
(
"git+https://git.example.com/sdispater/project/my_repo.git",
GitUrl("https://git.example.com/sdispater/project/my_repo.git", None),
),
(
"git+ssh://git@git.example.com:sdispater/project/my_repo.git",
GitUrl("git@git.example.com:sdispater/project/my_repo.git", None),
),
], ],
) )
def test_normalize_url(url, normalized): def test_normalize_url(url, normalized):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment