Skip to content

Commit

Permalink
feat: emit post_lock after writing pyproject.toml and pdm.lock in add…
Browse files Browse the repository at this point in the history
…/update (#3291)
  • Loading branch information
jantrienes authored Nov 15, 2024
1 parent 3110fce commit d1dc03d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/3285.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Emit `post_lock` after writing pyproject.toml and pdm.lock in add/update
2 changes: 1 addition & 1 deletion src/pdm/cli/commands/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ def do_add(
# Update dependency specifiers and lockfile hash.
deps_to_update = group_deps if unconstrained else requirements
save_version_specifiers(deps_to_update, resolved, save)
hooks.try_emit("post_lock", resolution=resolved, dry_run=dry_run)
if not dry_run:
project.add_dependencies(deps_to_update, group, selection.dev or False)
project.write_lockfile(project.lockfile._data, False)
hooks.try_emit("post_lock", resolution=resolved, dry_run=dry_run)
if sync:
do_sync(
project,
Expand Down
2 changes: 1 addition & 1 deletion src/pdm/cli/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ def do_update(
hooks=hooks,
groups=locked_groups,
)
hooks.try_emit("post_lock", resolution=resolved, dry_run=dry_run)
if unconstrained:
# Need to update version constraints
save_version_specifiers(chain.from_iterable(updated_deps.values()), resolved, save)
Expand All @@ -196,6 +195,7 @@ def do_update(
for group, deps in updated_deps.items():
project.add_dependencies(deps, group, selection.dev or False)
project.write_lockfile(project.lockfile._data, False)
hooks.try_emit("post_lock", resolution=resolved, dry_run=dry_run)
if sync or dry_run:
do_sync(
project,
Expand Down

0 comments on commit d1dc03d

Please sign in to comment.