diff --git a/news/6136.bugfix.rst b/news/6136.bugfix.rst new file mode 100644 index 000000000..6ddd3742c --- /dev/null +++ b/news/6136.bugfix.rst @@ -0,0 +1 @@ +Fix a bug that vcs subdependencies were locked without their subdirectory fragment if they had one diff --git a/pipenv/utils/locking.py b/pipenv/utils/locking.py index 019036b00..771466b5e 100644 --- a/pipenv/utils/locking.py +++ b/pipenv/utils/locking.py @@ -14,6 +14,7 @@ clean_resolved_dep, determine_vcs_revision_hash, expansive_install_req_from_line, + normalize_vcs_url, pep423_name, translate_markers, ) @@ -61,9 +62,16 @@ def format_requirement_for_lockfile( if req.link and req.link.is_vcs: vcs = req.link.scheme.split("+", 1)[0] entry["ref"] = determine_vcs_revision_hash(req, vcs, pipfile_entry.get("ref")) - entry[vcs] = original_deps.get(name, req.link.url) + + if name in original_deps: + entry[vcs] = original_deps[name] + else: + vcs_url, _ = normalize_vcs_url(req.link.url) + entry[vcs] = vcs_url if pipfile_entry.get("subdirectory"): entry["subdirectory"] = pipfile_entry["subdirectory"] + elif req.link.subdirectory_fragment: + entry["subdirectory"] = req.link.subdirectory_fragment if req.req: entry["version"] = str(req.specifier) elif version: diff --git a/tests/integration/test_lock.py b/tests/integration/test_lock.py index 99f5cd559..4d6fc3387 100644 --- a/tests/integration/test_lock.py +++ b/tests/integration/test_lock.py @@ -532,7 +532,8 @@ def test_lock_nested_vcs_direct_url(pipenv_instance_pypi): assert "git" in p.lockfile["default"]["pep508-package"] assert "sibling-package" in p.lockfile["default"] assert "git" in p.lockfile["default"]["sibling-package"] - assert "subdirectory" in p.lockfile["default"]["sibling-package"]["git"] + assert "subdirectory" in p.lockfile["default"]["sibling-package"] + assert p.lockfile["default"]["sibling-package"]["subdirectory"] == "parent_folder/sibling_package" assert "version" not in p.lockfile["default"]["sibling-package"]