Skip to content

Commit

Permalink
fix(parse_git_url): fix bad url with dash
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelA authored and relekang committed Feb 25, 2024
1 parent 82bfcd3 commit 1c25b8e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion semantic_release/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def parse_git_url(url: str) -> ParsedGitUrl:
(r"^git\+ssh://", "ssh://"),
# normalize an scp like syntax to URL compatible syntax
# excluding port definitions (:#####) & including numeric usernames
(r"(ssh://(?:\w+@)?[\w.]+):(?!\d{1,5}/\w+/)(.*)$", r"\1/\2"),
(r"(ssh://(?:\w+@)?[\w.-]+):(?!\d{1,5}/\w+/)(.*)$", r"\1/\2"),
# normalize implicit file (windows || posix) urls to explicit file:// urls
(r"^([C-Z]:/)|^/(\w)", r"file:///\1\2"),
]
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/semantic_release/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"http://git.mycompany.com/username/myproject.git",
ParsedGitUrl("http", "git.mycompany.com", "username", "myproject"),
),
(
"http://subsubdomain.subdomain.company-net.com/username/myproject.git",
ParsedGitUrl("http", "subsubdomain.subdomain.company-net.com", "username", "myproject"),
),
(
"https://github.com/username/myproject.git",
ParsedGitUrl("https", "github.com", "username", "myproject"),
Expand All @@ -22,6 +26,10 @@
"https://git.mycompany.com:4443/username/myproject.git",
ParsedGitUrl("https", "git.mycompany.com:4443", "username", "myproject"),
),
(
"https://subsubdomain.subdomain.company-net.com/username/myproject.git",
ParsedGitUrl("https", "subsubdomain.subdomain.company-net.com", "username", "myproject"),
),
(
"git://host.xz/path/to/repo.git/",
ParsedGitUrl("git", "host.xz", "path/to", "repo"),
Expand All @@ -34,6 +42,10 @@
"git@github.com:username/myproject.git",
ParsedGitUrl("ssh", "git@github.com", "username", "myproject"),
),
(
"git@subsubdomain.subdomain.company-net.com:username/myproject.git",
ParsedGitUrl("ssh", "git@subsubdomain.subdomain.company-net.com", "username", "myproject"),
),
(
"ssh://git@github.com:3759/myproject.git",
ParsedGitUrl("ssh", "git@github.com", "3759", "myproject"),
Expand All @@ -46,6 +58,10 @@
"ssh://git@bitbucket.org:7999/username/myproject.git",
ParsedGitUrl("ssh", "git@bitbucket.org:7999", "username", "myproject"),
),
(
"ssh://git@subsubdomain.subdomain.company-net.com:username/myproject.git",
ParsedGitUrl("ssh", "git@subsubdomain.subdomain.company-net.com", "username", "myproject"),
),
(
"git+ssh://git@github.com:username/myproject.git",
ParsedGitUrl("ssh", "git@github.com", "username", "myproject"),
Expand Down

0 comments on commit 1c25b8e

Please sign in to comment.