Skip to content

Commit 60a7c83

Browse files
Add nested vcs dependency subdirectory when locking to Pipfile.lock
1 parent ba7584d commit 60a7c83

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pipenv/utils/locking.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
clean_resolved_dep,
1515
determine_vcs_revision_hash,
1616
expansive_install_req_from_line,
17+
normalize_vcs_url,
1718
pep423_name,
1819
translate_markers,
1920
)
@@ -61,9 +62,16 @@ def format_requirement_for_lockfile(
6162
if req.link and req.link.is_vcs:
6263
vcs = req.link.scheme.split("+", 1)[0]
6364
entry["ref"] = determine_vcs_revision_hash(req, vcs, pipfile_entry.get("ref"))
64-
entry[vcs] = original_deps.get(name, req.link.url)
65+
66+
if name in original_deps:
67+
entry[vcs] = original_deps[name]
68+
else:
69+
vcs_url, _ = normalize_vcs_url(req.link.url)
70+
entry[vcs] = vcs_url
6571
if pipfile_entry.get("subdirectory"):
6672
entry["subdirectory"] = pipfile_entry["subdirectory"]
73+
elif req.link.subdirectory_fragment:
74+
entry["subdirectory"] = req.link.subdirectory_fragment
6775
if req.req:
6876
entry["version"] = str(req.specifier)
6977
elif version:

tests/integration/test_lock.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ def test_lock_nested_vcs_direct_url(pipenv_instance_pypi):
532532
assert "git" in p.lockfile["default"]["pep508-package"]
533533
assert "sibling-package" in p.lockfile["default"]
534534
assert "git" in p.lockfile["default"]["sibling-package"]
535-
assert "subdirectory" in p.lockfile["default"]["sibling-package"]["git"]
535+
assert "subdirectory" in p.lockfile["default"]["sibling-package"]
536+
assert p.lockfile["default"]["sibling-package"]["subdirectory"] == "parent_folder/sibling_package"
536537
assert "version" not in p.lockfile["default"]["sibling-package"]
537538

538539

0 commit comments

Comments
 (0)