Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue for projects with an at sign (@) in the path #310

Merged
merged 6 commits into from
Jun 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/309.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix an issue for projects with an at sign (``@``) in the path
2 changes: 1 addition & 1 deletion src/requirementslib/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def split_ref_from_uri(uri):
path = parsed.path if parsed.path else ""
scheme = parsed.scheme if parsed.scheme else ""
ref = None
if scheme != "file" and "@" in path:
if scheme != "file" and (re.match("^.*@[^/@]*$", path) or path.count("@") >= 2):
path, _, ref = path.rpartition("@")
parsed = parsed._replace(path=path)
return (parsed.url, ref)
Expand Down
29 changes: 29 additions & 0 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,35 @@ def test_split_vcs_method_from_uri():
)


def test_split_ref_from_uri():
assert utils.split_ref_from_uri("https://github.com/sarugaku/plette.git") == (
"https://github.com/sarugaku/plette.git",
None,
)
assert utils.split_ref_from_uri("/Users/some.user@acme.com/dev/myproject") == (
"/Users/some.user@acme.com/dev/myproject",
None,
)
assert utils.split_ref_from_uri(
"https://user:password@github.com/sarugaku/plette.git"
) == (
"https://user:password@github.com/sarugaku/plette.git",
None,
)
assert utils.split_ref_from_uri(
"git+https://github.com/pypa/pipenv.git@master#egg=pipenv"
) == (
"git+https://github.com/pypa/pipenv.git#egg=pipenv",
"master",
)
assert utils.split_ref_from_uri(
"/Users/some.user@acme.com/dev/myproject@bugfix/309"
) == (
"/Users/some.user@acme.com/dev/myproject",
"bugfix/309",
)


# tests from pip-tools


Expand Down