Skip to content

Commit

Permalink
Include hashes for file URLs
Browse files Browse the repository at this point in the history
Fix #1103
  • Loading branch information
frostming committed Jun 1, 2022
1 parent 759aef0 commit 1a1f874
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions news/1103.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug that the hashes for file URLs are not included in the lock file.
13 changes: 8 additions & 5 deletions pdm/models/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,16 @@ def get_hashes(self, candidate: Candidate) -> dict[str, str] | None:
matching_candidates: Iterable[Candidate] = [candidate]
else:
matching_candidates = self.find_candidates(req, True)
result: dict[str, str] = {}
with self.environment.get_finder(self.sources) as finder:
self._hash_cache.session = finder.session # type: ignore
return {
c.link.filename: self._hash_cache.get_hash(c.link) # type: ignore
for c in matching_candidates
if c.link and not c.link.is_vcs
} or None
for c in matching_candidates:
link = c.prepare(self.environment).ireq.link
if not link or link.is_vcs:
continue
result[link.filename] = self._hash_cache.get_hash(link)

return result or None

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

0 comments on commit 1a1f874

Please sign in to comment.