Skip to content

Commit

Permalink
Fix neglected subdirectory in dependency lock
Browse files Browse the repository at this point in the history
  • Loading branch information
juneoh committed Jan 20, 2023
1 parent 7279a07 commit da749da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/poetry/packages/locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ def _dump_package(self, package: Package) -> dict[str, Any]:
constraint["tag"] = dependency.tag
elif dependency.rev:
constraint["rev"] = dependency.rev

if dependency.directory:
constraint["subdirectory"] = dependency.directory

else:
constraint["version"] = str(dependency.pretty_constraint)

Expand Down
10 changes: 10 additions & 0 deletions tests/packages/test_locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,15 @@ def test_locker_dumps_dependency_information_correctly(
"F", {"git": "https://github.com/python-poetry/poetry.git", "branch": "foo"}
)
)
package_a.add_dependency(
Factory.create_dependency(
"G",
{
"git": "https://github.com/python-poetry/poetry.git",
"subdirectory": "bar",
},
)
)

packages = [package_a]

Expand All @@ -856,6 +865,7 @@ def test_locker_dumps_dependency_information_correctly(
D = {{path = "distributions/demo-0.1.0.tar.gz"}}
E = {{url = "https://python-poetry.org/poetry-1.2.0.tar.gz"}}
F = {{git = "https://github.com/python-poetry/poetry.git", branch = "foo"}}
G = {{git = "https://github.com/python-poetry/poetry.git", subdirectory = "bar"}}
[metadata]
lock-version = "2.0"
Expand Down

0 comments on commit da749da

Please sign in to comment.