Skip to content

Commit

Permalink
fix (git.py): git url's can now contain longer path names, e.g. proje…
Browse files Browse the repository at this point in the history
…cts like in gitlab (#1756)
  • Loading branch information
finswimmer authored and sdispater committed Dec 24, 2019
1 parent dbe2c38 commit 275d09f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
27 changes: 14 additions & 13 deletions poetry/vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@


PATTERNS = [
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"((?P<protocol>\w+)://)"
r"((?P<user>\w+)@)?"
r"(?P<resource>[\w.\-]+)"
r"(:(?P<port>\d+))?"
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"$"
),
re.compile(
r"^(?:(?P<user>.+)@)*"
r"(?P<resource>[a-z0-9_.-]*)[:]*"
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"$"
),
Expand All @@ -43,6 +43,7 @@
r"(?P<resource>[\w.\-]+)"
r"[:/]{1,2}"
r"(?P<pathname>((?P<owner>\w+)/)?"
r"(?P<projects>([\w\-/]+)/)?"
r"((?P<name>[\w\-]+)(\.git|/)?)?)"
r"([@#](?P<rev>[^@#]+))?"
r"$"
Expand Down
8 changes: 8 additions & 0 deletions tests/vcs/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 275d09f

Please sign in to comment.