Skip to content

Preserve additional_dependencies order and use synthetic local repo for local hooks#1609

Draft
shaanmajid wants to merge 1 commit intoj178:masterfrom
shaanmajid:fix/1602-1603-origin-cleanone
Draft

Preserve additional_dependencies order and use synthetic local repo for local hooks#1609
shaanmajid wants to merge 1 commit intoj178:masterfrom
shaanmajid:fix/1602-1603-origin-cleanone

Conversation

@shaanmajid
Copy link
Collaborator

Summary

  • Replace FxHashSet<String> with Vec<String> for additional_dependencies throughout the codebase, preserving user-specified ordering and duplicates. This matches pre-commit semantics and fixes hooks that
    pass non-dependency arguments (e.g., --index-url <url>) in additional_dependencies.
  • For repo: local Python hooks with additional_dependencies, install from a synthetic placeholder repository (matching pre-commit's pre-commit-placeholder-package) instead of the project root. This prevents
    . from depending on user project contents.

Closes #1602
Closes #1603

Notes

  • Existing cached hook environments will be re-created on upgrade due to the FxHashSetVec serialization change. One-time cost, no user action needed in most cases.
  • Users with existing cached repo: local Python hooks using . in additional_dependencies should run prek clean to pick up the new synthetic repo behavior.
  • This fix is Python-specific for the synthetic local repo. Other languages with repo: local are not affected.

@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

❌ Patch coverage is 92.19858% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.66%. Comparing base (4406340) to head (a9687f7).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
crates/prek/src/languages/python/python.rs 66.66% 6 Missing ⚠️
crates/prek/src/hook.rs 95.23% 4 Missing ⚠️
crates/prek/src/store.rs 88.88% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@prek-ci-bot
Copy link

prek-ci-bot bot commented Feb 9, 2026

📦 Cargo Bloat Comparison

Binary size change: +0.00% (23.7 MiB → 23.7 MiB)

Expand for cargo-bloat output

Head Branch Results

 File  .text    Size             Crate Name
 0.3%   0.8% 80.0KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.3%   0.7% 71.2KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6% 65.6KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 54.4KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.5% 51.2KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.4% 43.4KiB              prek prek::identify::by_extension::{{closure}}
 0.2%   0.4% 41.1KiB              prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4% 38.8KiB              prek prek::run::{{closure}}
 0.1%   0.3% 32.0KiB             prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 28.4KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2% 24.8KiB             prek? <prek::config::_::<impl serde_core::de::Deserialize for prek::config::Config>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 22.6KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2% 22.2KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 21.1KiB      clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 20.4KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 20.2KiB              prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
 0.1%   0.2% 19.8KiB              prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 19.7KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2% 19.5KiB              prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 19.4KiB   cargo_metadata? <cargo_metadata::_::<impl serde_core::de::Deserialize for cargo_metadata::Package>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
38.3%  91.4%  9.1MiB                   And 20911 smaller methods. Use -n N to show more.
41.9% 100.0% 10.0MiB                   .text section size, the file size is 23.7MiB

Base Branch Results

 File  .text    Size             Crate Name
 0.3%   0.7% 70.6KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.3%   0.7% 70.3KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6% 65.6KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 51.2KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.5% 50.5KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.4% 43.4KiB              prek prek::identify::by_extension::{{closure}}
 0.2%   0.4% 41.8KiB              prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4% 38.8KiB              prek prek::run::{{closure}}
 0.1%   0.3% 32.0KiB             prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 28.4KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2% 24.8KiB             prek? <prek::config::_::<impl serde_core::de::Deserialize for prek::config::Config>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 22.6KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2% 22.2KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 22.2KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 21.1KiB      clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 20.0KiB   cargo_metadata? <cargo_metadata::_::<impl serde_core::de::Deserialize for cargo_metadata::Package>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 19.8KiB              prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 19.6KiB              prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 19.3KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2% 19.2KiB              prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
38.4%  91.5%  9.1MiB                   And 20946 smaller methods. Use -n N to show more.
42.0% 100.0% 10.0MiB                   .text section size, the file size is 23.7MiB

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
@shaanmajid shaanmajid force-pushed the fix/1602-1603-origin-cleanone branch from a9687f7 to 2b719ef Compare February 9, 2026 05:23
@j178 j178 self-assigned this Feb 18, 2026
@j178 j178 requested a review from Copilot February 18, 2026 13:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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> with Vec<String> for hook dependency tracking/env keys to preserve order and duplicates.
  • For Python repo: local hooks with additional_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants