From 8da21ce51da9e2c3cfa22bdaf7721910d4fb0840 Mon Sep 17 00:00:00 2001 From: finswimmer Date: Tue, 24 Dec 2019 16:11:36 +0100 Subject: [PATCH] fix (git.py): git url's can now contain longer path names, e.g. projects like in gitlab (#1756) --- poetry/vcs/git.py | 27 ++++++++++++++------------- tests/vcs/test_git.py | 8 ++++++++ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/poetry/vcs/git.py b/poetry/vcs/git.py index 4a5e0e0272a..b983392b7ed 100644 --- a/poetry/vcs/git.py +++ b/poetry/vcs/git.py @@ -8,17 +8,6 @@ PATTERNS = [ - re.compile( - r"^(git\+)?" - r"(?Phttps?|git|ssh|rsync|file)://" - r"(?:(?P.+)@)*" - r"(?P[a-z0-9_.-]*)" - r"(:?P[\d]+)?" - r"(?P[:/]((?P[\w\-]+)/)?" - r"((?P[\w\-.]+?)(\.git|/)?)?)" - r"([@#](?P[^@#]+))?" - r"$" - ), re.compile( r"(git\+)?" r"((?P\w+)://)" @@ -26,7 +15,18 @@ r"(?P[\w.\-]+)" r"(:(?P\d+))?" r"(?P(/(?P\w+)/)" - r"(/?(?P[\w\-]+)(\.git|/)?)?)" + r"((?P([\w\-/]+)/)?(?P[\w\-]+)(\.git|/)?)?)" + r"([@#](?P[^@#]+))?" + r"$" + ), + re.compile( + r"^(git\+)?" + r"(?Phttps?|git|ssh|rsync|file)://" + r"(?:(?P.+)@)*" + r"(?P[a-z0-9_.-]*)" + r"(:?P[\d]+)?" + r"(?P[:/]((?P[\w\-]+)/(?P([\w\-/]+)/)?)?" + r"((?P[\w\-.]+?)(\.git|/)?)?)" r"([@#](?P[^@#]+))?" r"$" ), @@ -34,7 +34,7 @@ r"^(?:(?P.+)@)*" r"(?P[a-z0-9_.-]*)[:]*" r"(?P[\d]+)?" - r"(?P/?(?P.+)/(?P.+).git)" + r"(?P/?(?P.+)/(?P([\w\-/]+)/)?(?P.+).git)" r"([@#](?P[^@#]+))?" r"$" ), @@ -43,6 +43,7 @@ r"(?P[\w.\-]+)" r"[:/]{1,2}" r"(?P((?P\w+)/)?" + r"(?P([\w\-/]+)/)?" r"((?P[\w\-]+)(\.git|/)?)?)" r"([@#](?P[^@#]+))?" r"$" diff --git a/tests/vcs/test_git.py b/tests/vcs/test_git.py index 945084be15c..667294ee614 100644 --- a/tests/vcs/test_git.py +++ b/tests/vcs/test_git.py @@ -62,6 +62,14 @@ "git+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):