Skip to content

Commit

Permalink
Try to match if the part after @ is a valid ref (reject treating URL …
Browse files Browse the repository at this point in the history
…parts as refs). (#5856)

* Try to match ref only if the part after @ is a valid ref (reject treating URL parts as refs).
  • Loading branch information
matteius committed Aug 22, 2023
1 parent 0501f9b commit a78cad8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions news/5849.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
More gracefully handle @ symbols in vcs URLs to address recent regression with vcs URLs.
5 changes: 3 additions & 2 deletions pipenv/utils/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,8 +981,9 @@ def install_req_from_pipfile(name, pipfile):
"ssh://" not in vcs_url and "@" in vcs_url
):
vcs_url_parts = vcs_url.rsplit("@", 1)
vcs_url = vcs_url_parts[0]
fallback_ref = vcs_url_parts[1]
if re.match(r"^[\w\.]+$", vcs_url_parts[1]):
vcs_url = vcs_url_parts[0]
fallback_ref = vcs_url_parts[1]
req_str = f"{vcs_url}@{_pipfile.get('ref', fallback_ref)}{extras_str}"
if not req_str.startswith(f"{vcs}+"):
req_str = f"{vcs}+{req_str}"
Expand Down
8 changes: 5 additions & 3 deletions pipenv/utils/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ def requirement_from_lockfile(
"ssh://" not in url and "@" in url
):
url_parts = url.rsplit("@", 1)
url = url_parts[0]
if not ref:
ref = url_parts[1]
# Check if the second part matches the criteria to be a ref (vcs URLs would likely have a /)
if re.match(r"^[\w\.]+$", url_parts[1]):
url = url_parts[0]
if not ref:
ref = url_parts[1]

extras = (
"[{}]".format(",".join(package_info.get("extras", [])))
Expand Down

0 comments on commit a78cad8

Please sign in to comment.