Skip to content

Commit

Permalink
fix: Struggling with installs from git -- `unearth.errors.UnpackError…
Browse files Browse the repository at this point in the history
…: fatal: couldn't find remote ref unknown`

Fixes #3107

Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming committed Aug 15, 2024
1 parent 761a4f2 commit ea9c1de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/3107.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug that the VCS revision is lost if the candidate metadata is cached during resolution.
5 changes: 5 additions & 0 deletions src/pdm/models/candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class Candidate:
"_prepared",
"_requires_python",
"_preferred",
"_revision",
)

def __init__(
Expand All @@ -155,6 +156,7 @@ def __init__(

self._requires_python: str | None = None
self._prepared: PreparedCandidate | None = None
self._revision = getattr(req, "revision", None)

def identify(self) -> str:
return self.req.identify()
Expand All @@ -165,6 +167,7 @@ def copy_with(self, requirement: Requirement) -> Candidate:
can.hashes = self.hashes
can._requires_python = self._requires_python
can._prepared = self._prepared
can._revision = self._revision
if can._prepared:
can._prepared.req = requirement
return can
Expand Down Expand Up @@ -192,6 +195,8 @@ def __eq__(self, other: Any) -> bool:
def get_revision(self) -> str:
if not self.req.is_vcs:
raise AttributeError("Non-VCS candidate doesn't have revision attribute")
if self._revision:
return self._revision
if self.req.revision: # type: ignore[attr-defined]
return self.req.revision # type: ignore[attr-defined]
return self._prepared.revision if self._prepared else "unknown"
Expand Down

0 comments on commit ea9c1de

Please sign in to comment.