Skip to content

Commit 1a1f874

Browse files
committed
Include hashes for file URLs
Fix #1103
1 parent 759aef0 commit 1a1f874

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

news/1103.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug that the hashes for file URLs are not included in the lock file.

pdm/models/repositories.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,16 @@ def get_hashes(self, candidate: Candidate) -> dict[str, str] | None:
211211
matching_candidates: Iterable[Candidate] = [candidate]
212212
else:
213213
matching_candidates = self.find_candidates(req, True)
214+
result: dict[str, str] = {}
214215
with self.environment.get_finder(self.sources) as finder:
215216
self._hash_cache.session = finder.session # type: ignore
216-
return {
217-
c.link.filename: self._hash_cache.get_hash(c.link) # type: ignore
218-
for c in matching_candidates
219-
if c.link and not c.link.is_vcs
220-
} or None
217+
for c in matching_candidates:
218+
link = c.prepare(self.environment).ireq.link
219+
if not link or link.is_vcs:
220+
continue
221+
result[link.filename] = self._hash_cache.get_hash(link)
222+
223+
return result or None
221224

222225
def dependency_generators(self) -> Iterable[Callable[[Candidate], CandidateInfo]]:
223226
"""Return an iterable of getter functions to get dependencies, which will be

0 commit comments

Comments
 (0)