poetry icon indicating copy to clipboard operation
poetry copied to clipboard

`poetry update` doesn't update git dependencies that specify branch but not revision

Open triopter opened this issue 11 months ago • 5 comments

The workaround suggested in https://github.com/python-poetry/poetry/issues/6046#issuecomment-1191941286_ is to run poetry update. But if you've specified a branch for your git repo, poetry update <dependency_name> doesn't update the resolved_reference commit specification.

So imagine a pyproject.toml with the following:

[tool.poetry.dependencies]
# ...
my_dep = { git = "[email protected]:whatever/my-dep.git", develop = true, branch="main" }
# ...

And say the HEAD of the main branch is commit abcd1234.... After poetry install, poetry.lock will contain something like:

[[package]]
name = "my_dep"
version = "0.1"
optional = false
python-versions = "*"
files = []
develop = true

[package.dependencies]
# ...

[package.source]
type = "git"
url = "[email protected]:whatever/my-dep.git"
reference = "main"
resolved_reference = "abcd1234..."

Now I make another commit on main and push to github. Now the HEAD of the main branch is commit 9876fedc...

The expected behavior is that poetry update my_dep will update poetry.lock to look like this:

[[package]]
name = "my_dep"
version = "0.1"
optional = false
python-versions = "*"
files = []
develop = true

[package.dependencies]
# ...

[package.source]
type = "git"
url = "[email protected]:whatever/my-dep.git"
reference = "main"
resolved_reference = "9876fedc..."

The actual behavior is that poetry.lock is unchanged, still containing:

resolved_reference = "abcd1234..."

Obviously we don't want poetry install to entirely ignore the resolved_reference, which is the bug fixed in #2921, to my understanding. But it should still be possible to update the locked commit in resolved_reference when explicitly requested.

triopter avatar Jan 12 '25 18:01 triopter

Thank you Matt ❤️

saoudrizwan avatar Jan 14 '25 20:01 saoudrizwan