Skip to content

Conversation

@drainpixie
Copy link
Contributor

@drainpixie drainpixie commented Dec 3, 2025

Closes #1177. I'm aware right now the PR lacks documentation and test changes; I wanted to get a code review first to ensure my approach is correct as it's my first time with this codebase. I have tested the current changes manually as such:

~/p/o/testing main (nix) $ cat .pre-commit-config.yaml
repos:
  - repo: local
    hooks:
      - id:  foo
        name: Foo 
        entry: echo "foo"
        language: system
        stages: [commit]

      - id: bar 
        name: Bar 
        entry: echo "Bar"
        language: system
        stages: [manual]

      - id: baz
        name: Baz
        entry: echo "Baz"
        language: system
        stages: [manual]

~/p/o/testing main (nix) $ prek    
Foo..................................................(no files to check)Skipped
~/p/o/testing main (nix) $ prek bar
error: No hooks found for stage `pre-commit` after filtering
~/p/o/testing main (nix) $ ../prek/target/debug/prek
Foo..................................................(no files to check)Skipped
~/p/o/testing main (nix) $ ../prek/target/debug/prek bar
warning: No hooks found for stage `pre-commit` after filtering; running with `--hook-stage manual --all-files` as the selected hook(s) support the `manual` stage.
Bar......................................................................Passed
~/p/o/testing main (nix) $ ../prek/target/debug/prek bar baz
warning: No hooks found for stage `pre-commit` after filtering; running with `--hook-stage manual --all-files` as the selected hook(s) support the `manual` stage.
Bar......................................................................Passed
Baz......................................................................Passed
~/p/o/testing main (nix) $ 

@potiuk
Copy link

potiuk commented Dec 5, 2025

I think the interesting cases to add also as manual tests are :

  • ~/p/o/testing main (nix) $ ../prek/target/debug/prek foo -> should work in commit mode
  • ~/p/o/testing main (nix) $ ../prek/target/debug/prek foo bar baz (should we only run foo, or foo as commit and bar/bas as manual or fail whole command)

@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 97.05882% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.74%. Comparing base (b5be7c6) to head (d1d8179).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
src/cli/run/selector.rs 85.71% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1185   +/-   ##
=======================================
  Coverage   89.73%   89.74%           
=======================================
  Files          78       78           
  Lines       14767    14796   +29     
=======================================
+ Hits        13251    13278   +27     
- Misses       1516     1518    +2     

☔ 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.

@github-actions
Copy link

github-actions bot commented Dec 5, 2025

📦 Cargo Bloat Comparison

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

Expand for cargo-bloat output

Head Branch Results

 File  .text     Size          Crate Name
 0.6%   1.3% 104.8KiB          prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.6%   1.3% 100.4KiB           prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.7%  54.6KiB           prek prek::archive::unpack::{{closure}}
 0.3%   0.7%  53.0KiB             h2 h2::proto::connection::Connection<T,P,B>::poll
 0.3%   0.6%  48.6KiB           prek prek::run::{{closure}}
 0.2%   0.5%  40.0KiB           prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.5%  39.1KiB          prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.2%   0.5%  37.3KiB regex_automata regex_automata::meta::strategy::new
 0.2%   0.4%  35.2KiB           prek prek::workspace::Workspace::discover
 0.2%   0.4%  31.4KiB           std? <core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize
 0.2%   0.4%  30.4KiB           prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4%  28.8KiB           prek prek::languages::node::installer::NodeInstaller::install::{{closure}}
 0.2%   0.4%  28.1KiB             h2 h2::proto::connection::DynConnection<B>::recv_frame
 0.2%   0.3%  27.6KiB           prek prek::identify::by_extension::{{closure}}
 0.1%   0.3%  25.1KiB           prek prek::main
 0.1%   0.3%  24.4KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.3%  24.4KiB           std? <core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize
 0.1%   0.3%  24.3KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::connect_to::{{closure}}::{{closure}}::{{closure}}
 0.1%   0.3%  24.2KiB           prek prek::hook::HookBuilder::build::{{closure}}
 0.1%   0.3%  23.9KiB          hyper hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
41.1%  88.8%   6.8MiB                And 10630 smaller methods. Use -n N to show more.
46.3% 100.0%   7.7MiB                .text section size, the file size is 16.7MiB

Base Branch Results

 File  .text     Size          Crate Name
 0.6%   1.3% 104.8KiB          prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.6%   1.3% 100.4KiB           prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.7%  54.6KiB           prek prek::archive::unpack::{{closure}}
 0.3%   0.7%  53.0KiB             h2 h2::proto::connection::Connection<T,P,B>::poll
 0.3%   0.6%  48.6KiB           prek prek::run::{{closure}}
 0.2%   0.5%  40.0KiB           prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.5%  39.2KiB          prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.2%   0.5%  37.3KiB regex_automata regex_automata::meta::strategy::new
 0.2%   0.4%  35.2KiB           prek prek::workspace::Workspace::discover
 0.2%   0.4%  31.4KiB           std? <core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize
 0.2%   0.4%  30.1KiB           prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4%  28.8KiB           prek prek::languages::node::installer::NodeInstaller::install::{{closure}}
 0.2%   0.4%  28.1KiB             h2 h2::proto::connection::DynConnection<B>::recv_frame
 0.2%   0.3%  27.6KiB           prek prek::identify::by_extension::{{closure}}
 0.1%   0.3%  25.1KiB           prek prek::main
 0.1%   0.3%  24.4KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.3%  24.4KiB           std? <core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize
 0.1%   0.3%  24.3KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::connect_to::{{closure}}::{{closure}}::{{closure}}
 0.1%   0.3%  24.2KiB           prek prek::hook::HookBuilder::build::{{closure}}
 0.1%   0.3%  23.9KiB          hyper hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
41.1%  88.8%   6.8MiB                And 10633 smaller methods. Use -n N to show more.
46.3% 100.0%   7.7MiB                .text section size, the file size is 16.7MiB

@j178 j178 changed the title feat: simplify manual hooks workflow Fallback to manual stage for hooks specified in cli Dec 5, 2025
@j178 j178 added the enhancement New feature or request label Dec 5, 2025
@j178 j178 changed the title Fallback to manual stage for hooks specified in cli Fallback to manual stage for hooks specified directly in command line Dec 5, 2025
@j178
Copy link
Owner

j178 commented Dec 5, 2025

Thank! I removed the extra fallback to --all-files and kept only the manual-stage fallback. --all-files controls file selection, which is orthogonal to hook stages, so letting the stage toggle alter file discovery was confusing. Keeping the fallback scoped to manual makes the behavior easier to reason about without surprising changes to the file filter logic.

@j178 j178 merged commit adf7816 into j178:master Dec 5, 2025
21 checks passed
@drainpixie
Copy link
Contributor Author

Glad I could help :)

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make it easy to "force" running a hook from command line

3 participants