Preserve additional_dependencies order and use synthetic local repo for local hooks#1609
Preserve additional_dependencies order and use synthetic local repo for local hooks#1609shaanmajid wants to merge 1 commit intoj178:masterfrom
additional_dependencies order and use synthetic local repo for local hooks#1609Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1609 +/- ##
==========================================
- Coverage 91.68% 91.66% -0.02%
==========================================
Files 94 94
Lines 18387 18516 +129
==========================================
+ Hits 16858 16973 +115
- Misses 1529 1543 +14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📦 Cargo Bloat ComparisonBinary size change: +0.00% (23.7 MiB → 23.7 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
Replace FxHashSet<String> with Vec<String> for additional_dependencies throughout the codebase. This preserves user-specified ordering and duplicates, matching pre-commit semantics. Previously, FxHashSet caused arbitrary reordering that broke hooks passing non-dependency arguments like `--index-url <url>` in additional_dependencies. For `repo: local` Python hooks, install from a synthetic placeholder repository (containing a minimal setup.py) instead of the project root. This prevents `.` in additional_dependencies from depending on project contents and matches pre-commit's behavior. Closes j178#1602 Closes j178#1603
a9687f7 to
2b719ef
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates prek’s hook dependency handling to match pre-commit semantics by preserving additional_dependencies ordering/duplicates (affecting env reuse keys and install args) and by making Python repo: local installs run against a synthetic placeholder repo instead of the user’s project root.
Changes:
- Replace
FxHashSet<String>withVec<String>for hook dependency tracking/env keys to preserve order and duplicates. - For Python
repo: localhooks withadditional_dependencies, install from a synthetic placeholder repo in the store rather than the project root. - Update tests and hashing/GC display logic to align with the new ordered dependency behavior.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/prek/src/hook.rs | Switch dependency storage/env-key logic to ordered Vec<String>; add regression test for order/dup preservation. |
| crates/prek/src/store.rs | Add synthetic local placeholder repo creation (local_repo_path). |
| crates/prek/src/languages/python/python.rs | Use synthetic local repo when installing additional deps for repo: local Python hooks. |
| crates/prek/src/languages/python/pep723.rs | Preserve PEP 723 dependency ordering by assigning the parsed list directly. |
| crates/prek/src/cli/cache_gc.rs | Update repo/deps splitting to operate on ordered dependency lists (no sorting). |
| crates/prek/src/languages/docker.rs | Hash dependencies directly as an ordered list for docker env naming. |
| crates/prek/src/languages/ruby/gem.rs | Update Ruby gem installer signature to accept ordered dependency slices. |
| crates/prek/src/languages/ruby/ruby.rs | Adjust dependency vector plumbing into InstallInfo. |
| crates/prek/src/languages/ruby/version.rs | Update tests for new InstallInfo dependency type. |
| crates/prek/src/languages/python/version.rs | Update tests for new InstallInfo dependency type. |
| crates/prek/src/languages/node/node.rs | Adjust dependency vector plumbing into InstallInfo. |
| crates/prek/src/languages/node/version.rs | Update tests for new InstallInfo dependency type. |
| crates/prek/src/languages/rust/rust.rs | Adjust dependency vector plumbing into InstallInfo. |
| crates/prek/src/languages/rust/version.rs | Update tests for new InstallInfo dependency type. |
| crates/prek/src/languages/swift.rs | Adjust dependency vector plumbing into InstallInfo. |
| crates/prek/src/languages/pygrep/pygrep.rs | Adjust dependency vector plumbing into InstallInfo. |
| crates/prek/src/languages/golang/golang.rs | Adjust dependency vector plumbing into InstallInfo. |
| crates/prek/src/languages/haskell.rs | Adjust dependency vector plumbing into InstallInfo. |
| crates/prek/src/languages/julia.rs | Adjust dependency vector plumbing into InstallInfo. |
| crates/prek/src/languages/lua.rs | Adjust dependency vector plumbing into InstallInfo. |
| crates/prek/src/languages/bun/bun.rs | Adjust dependency vector plumbing into InstallInfo. |
| crates/prek/tests/languages/python.rs | Add tests asserting placeholder-repo behavior for repo: local Python installs; adjust existing regression test setup. |
| crates/prek/tests/run.rs | Update env reuse test to use a real additional dependency (pyecho-cli) instead of a local package. |
Summary
FxHashSet<String>withVec<String>foradditional_dependenciesthroughout the codebase, preserving user-specified ordering and duplicates. This matches pre-commit semantics and fixes hooks thatpass non-dependency arguments (e.g.,
--index-url <url>) inadditional_dependencies.repo: localPython hooks withadditional_dependencies, install from a synthetic placeholder repository (matching pre-commit'spre-commit-placeholder-package) instead of the project root. This prevents.from depending on user project contents.Closes #1602
Closes #1603
Notes
FxHashSet→Vecserialization change. One-time cost, no user action needed in most cases.repo: localPython hooks using.inadditional_dependenciesshould runprek cleanto pick up the new synthetic repo behavior.repo: localare not affected.