Skip to content

Commit f0ab746

Browse files
committed
add news
Signed-off-by: Frost Ming <[email protected]>
1 parent f19b60e commit f0ab746

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

news/3595.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Re-caculate artifact files and hashes when the lock target changes.

src/pdm/cli/actions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,17 @@ def do_lock(
6262
if strategy_change and append:
6363
raise PdmUsageError("Not allowed to change lock strategy when --append is used.")
6464
locked_repo = project.get_locked_repository()
65+
candidates = [entry.candidate for entry in locked_repo.packages.values()]
66+
if refresh or env_spec is not None:
67+
# Refetch hashes if --platform/--python/--implementation/--refresh is used
68+
for c in candidates:
69+
c.hashes.clear()
6570
if refresh:
6671
if env_spec is not None:
6772
raise PdmUsageError("Cannot pass --python/--platform/--implementation with --refresh")
6873
repo = project.get_repository()
6974
with project.core.ui.open_spinner("Re-calculating hashes..."):
7075
with project.core.ui.logging("lock"):
71-
candidates = [entry.candidate for entry in locked_repo.packages.values()]
72-
for c in candidates:
73-
c.hashes.clear()
7476
repo.fetch_hashes(candidates)
7577
project.lockfile.format_lockfile(locked_repo, groups=project.lockfile.groups, strategy=lock_strategy)
7678
project.write_lockfile()

0 commit comments

Comments
 (0)