Skip to content

Conversation

@Goldziher
Copy link

@Goldziher Goldziher commented Dec 6, 2025

This PR adds support for glob patterns:

# Top-level defaults
  files:
    glob:
      - src/**/*.rs
      - crates/**/src/**/*.rs
  exclude:
    glob:
      - target/**
      - dist/**

  repos:
    - repo: local
      hooks:
        - id: fmt-rust
          entry: cargo fmt --all
          language: system
          # Single glob is fine too:
          files:
            glob: src/**/*.rs
          # Regex still works as before (default form
  without `glob:`):
          exclude: (^|/)vendor/.*

        - id: lint-js
          entry: pnpm lint
          language: system
          files:
            glob:
              - web/src/**/*.ts
              - web/src/**/*.tsx
          exclude:
            glob: web/src/**/__tests__/**

Why? The new monorepo support prek offers is nice, but its limited. In glob patterns enhance this further making prek much more versatile - globs are one of the key features of lefthook, that are missing. Furthermore, the pattern usage from pre-commit is inefficient and not very nice to work with - in my humble opinion, so this PR offers a completely backwards compatible alternative. Default is what it always was, while you can opt in to glob patterns.

@codecov
Copy link

codecov bot commented Dec 6, 2025

Codecov Report

❌ Patch coverage is 95.08929% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.57%. Comparing base (db20094) to head (f310ebe).

Files with missing lines Patch % Lines
src/hooks/meta_hooks.rs 88.67% 6 Missing ⚠️
src/config.rs 96.68% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1197      +/-   ##
==========================================
- Coverage   89.58%   89.57%   -0.01%     
==========================================
  Files          78       78              
  Lines       14823    15002     +179     
==========================================
+ Hits        13279    13438     +159     
- Misses       1544     1564      +20     

☔ 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 6, 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.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%  38.3KiB           prek prek::run::{{closure}}
 0.2%   0.5%  37.3KiB regex_automata regex_automata::meta::strategy::new
 0.2%   0.4%  35.6KiB           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.3KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::connect_to::{{closure}}::{{closure}}::{{closure}}
 0.1%   0.3%  24.0KiB           prek prek::hook::HookBuilder::build::{{closure}}
 0.1%   0.3%  23.9KiB           std? <core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize
 0.1%   0.3%  23.9KiB          hyper hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
41.2%  89.0%   6.9MiB                And 10657 smaller methods. Use -n N to show more.
46.4% 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.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%  38.3KiB           prek prek::run::{{closure}}
 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.2%  88.9%   6.9MiB                And 10629 smaller methods. Use -n N to show more.
46.3% 100.0%   7.7MiB                .text section size, the file size is 16.7MiB

@Goldziher
Copy link
Author

@j178 - hi. Can you enable running github actions for users who are not new to github? its an optional setting. It will make contributing here much simpler.

@j178 j178 added enhancement New feature or request needs decision labels Dec 7, 2025
@j178
Copy link
Owner

j178 commented Dec 8, 2025

Thanks for contributing — this looks good! But since this is a new feature, I’ll need a bit more time to think through the interface design and the overall user experience.

Also, dependencies are normally updated by the Renovate bot, so we usually don’t include them in feature PRs. It doesn’t look like they’re needed for this one, right?

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

Labels

enhancement New feature or request needs decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants