Skip to content

Implement check-case-conflict as builtin hook#888

Merged
j178 merged 7 commits intoj178:masterfrom
lmmx:check-case-conflict
Dec 18, 2025
Merged

Implement check-case-conflict as builtin hook#888
j178 merged 7 commits intoj178:masterfrom
lmmx:check-case-conflict

Conversation

@lmmx
Copy link
Collaborator

@lmmx lmmx commented Oct 14, 2025

Description

Implementing the check-case-conflict hook which ensures you don't check in files that would be the same on case-insensitive file systems (I think this is a Windows thing).

This is a widely used hook, 4.8k repos on grep.app.

  • No new dependencies.
  • It needed one new git function to mirror the equivalent one in the Python original implementation.
  • Unit tests and snapshot tests included

Binary Size Change
+0.63% (.text: 16.0 MiB → 16.1 MiB)

Demo

The most popular repo with this hook is jupyter/notebook

The hook takes 0.08s to run on pre-commit and 0.12s on prek (50% slower)

louis 🌟 ~/tmp/notebook $ runpc --verbose
check for case conflicts.................................................Passed
- hook id: check-case-conflict
- duration: 0.08s
check toml...............................................................Passed
- hook id: check-toml
- duration: 0.03s
check yaml...............................................................Passed
- hook id: check-yaml
- duration: 0.04s
louis 🌟 ~/tmp/notebook $ runpk --verbose
real    0m0.339s
user    0m1.255s
sys     0m0.292s
check for case conflicts.................................................Passed
- hook id: check-case-conflict
- duration: 0.12s
check toml...............................................................Passed
- hook id: check-toml
- duration: 0.00s
check yaml...............................................................Passed
- hook id: check-yaml
- duration: 0.00s

After installing from this local feature branch version, it runs instantly 🎉

louis 🌟 ~/tmp/notebook $ time runpk --verbose
check for case conflicts.................................................Passed
- hook id: check-case-conflict
- duration: 0.00s

@codecov
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

❌ Patch coverage is 98.80952% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.97%. Comparing base (d4adf8b) to head (2ca9d8a).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
crates/prek/src/hooks/pre_commit_hooks/mod.rs 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #888      +/-   ##
==========================================
+ Coverage   89.82%   89.97%   +0.14%     
==========================================
  Files          79       80       +1     
  Lines       15264    15405     +141     
==========================================
+ Hits        13711    13860     +149     
+ Misses       1553     1545       -8     

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

@lmmx
Copy link
Collaborator Author

lmmx commented Oct 14, 2025

Ha! The snapshots have broken on Windows and macOS because those filesystems are indeed case insensitive by default so the files are never produced so there is no conflict, as the filesystem prevents you from creating those files in the same directory so the conflicts never exist in the first place!

Screenshot from 2025-10-14 23-25-14

In which case: those tests should be skipped on those platforms

edit rather than skip those tests depending on platform, I returned early so as to confirm the assumption still holds (it did), now all the CI tests pass

@lmmx lmmx force-pushed the check-case-conflict branch from 21c27ed to 6127865 Compare October 14, 2025 22:35
@lmmx lmmx mentioned this pull request Oct 15, 2025
34 tasks
@lmmx lmmx force-pushed the check-case-conflict branch 6 times, most recently from 3876679 to 607b9f0 Compare October 19, 2025 10:27
@lemonyte
Copy link

This would be the last of the popular (>2k users) and not python-specific hooks that's missing. I'm one of the users who relies on this hook, so it would be awesome to see it merged!
Thanks @lmmx for your work and @j178 for the project!

lmmx and others added 3 commits December 18, 2025 11:29
# Conflicts:
#	crates/prek/src/hooks/pre_commit_hooks/check_case_conflict.rs
#	crates/prek/tests/builtin_hooks.rs
#	src/builtin/pre_commit_hooks/mod.rs
@j178 j178 force-pushed the check-case-conflict branch from 607b9f0 to 4ec1ae6 Compare December 18, 2025 03:35
@j178 j178 changed the title feat(check-case-conflict): implement builtin hook Implement check-case-conflict as builtin hook Dec 18, 2025
@j178 j178 added the enhancement New feature or request label Dec 18, 2025
@github-actions
Copy link

github-actions bot commented Dec 18, 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.4% 108.0KiB          prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.6%   1.2%  98.8KiB           prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.7%  54.3KiB           prek prek::archive::unpack::{{closure}}
 0.3%   0.7%  53.0KiB             h2 h2::proto::connection::Connection<T,P,B>::poll
 0.2%   0.5%  39.1KiB          prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.2%   0.5%  38.4KiB           prek prek::run::{{closure}}
 0.2%   0.5%  38.3KiB           prek prek::languages::<impl prek::config::Language>::install::{{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%  30.4KiB           prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4%  30.4KiB           std? <core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize
 0.2%   0.4%  30.2KiB           prek prek::languages::rust::installer::RustInstaller::install::{{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.8KiB           std? <core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize
 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.3KiB           prek prek::cli::auto_update::update_repo::{{closure}}
41.1%  88.9%   6.9MiB                And 10622 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.4% 108.0KiB          prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.6%   1.2%  98.5KiB           prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.7%  54.3KiB           prek prek::archive::unpack::{{closure}}
 0.3%   0.7%  53.0KiB             h2 h2::proto::connection::Connection<T,P,B>::poll
 0.2%   0.5%  39.1KiB          prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.2%   0.5%  38.4KiB           prek prek::run::{{closure}}
 0.2%   0.5%  38.3KiB           prek prek::languages::<impl prek::config::Language>::install::{{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%  30.4KiB           prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4%  30.4KiB           std? <core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize
 0.2%   0.4%  30.2KiB           prek prek::languages::rust::installer::RustInstaller::install::{{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.3KiB           prek prek::cli::auto_update::update_repo::{{closure}}
41.1%  88.9%   6.9MiB                And 10608 smaller methods. Use -n N to show more.
46.2% 100.0%   7.7MiB                .text section size, the file size is 16.7MiB

@j178 j178 force-pushed the check-case-conflict branch from 57ee4eb to b80057c Compare December 18, 2025 05:21
@j178 j178 force-pushed the check-case-conflict branch from b80057c to 9b0227b Compare December 18, 2025 05:25
@j178 j178 merged commit 5785a1a into j178:master Dec 18, 2025
21 checks passed
@j178
Copy link
Owner

j178 commented Dec 18, 2025

Thanks @lmmx!

@lmmx lmmx deleted the check-case-conflict branch December 18, 2025 11:03
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.

3 participants