1
0
mirror of https://github.com/j178/prek.git synced 2026-04-25 02:11:36 +02:00
Commit Graph

1204 Commits

Author SHA1 Message Date
Jo e62fffb256 Minor tweaks for parse_boolish (#1035) 2025-11-04 12:25:16 +08:00
nate nowack a8dbefe602 Add FastMCP to users list (#1034) 2025-11-04 10:46:43 +08:00
Steven Taylor e4334198f3 Move parse_boolish to EnvVars (#1030)
refactor parse boolish, moved into env_vars and additional convenience
method to read env var and treat as bool

Signed-off-by: Steven Taylor <steven@taylormuff.co.uk>
2025-11-04 03:21:18 +08:00
Copilot 011a0b3ff1 Rename crate lib/constants to crates/prek-consts and rename lib to crates (#1026)
* Initial plan

* Rename crate lib/constants to lib/prek-consts and fix all references

Co-authored-by: j178 <10510431+j178@users.noreply.github.com>

* Rename lib directory to crates and update all references

Co-authored-by: j178 <10510431+j178@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: j178 <10510431+j178@users.noreply.github.com>
2025-11-03 23:16:58 +08:00
Jo ee0acf25a3 Rename pty crate to prek-pty (#1025) 2025-11-03 22:16:22 +08:00
Jo f6d873c48e Vendor yaml-merge-keys to reduce dependencies (#1024) 2025-11-03 20:36:23 +08:00
renovate[bot] e14219154d Update taiki-e/install-action action to v2.62.45 (#1007)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-03 19:38:24 +08:00
Jo e608155aaf Disable renovate update for ilammy/msvc-dev-cmd (#1023) 2025-11-03 19:36:04 +08:00
is-alnilam d9baf0a5f1 Add Ruby support (no download support yet) (#993)
* Add Ruby support (no download support yet)

Currently only pre-existing Rubies are used, although the code will
search for and consider multiple versions. This allows a hook to require
3.4.7 when the default system Ruby is 3.4.6, but RVM (or a similar tool)
has installed 3.4.7. If a suitable Ruby cannot be found, the user is
prompted to install one manually and re-run.

Hooks get an isolated GEM_HOME, based on the hook repository, any
additional_dependencies, and the interpreter version/path. Any Ruby
upgrade would therefore re-install the gems to ensure that stale
versions aren't used. Repository gem dependencies are installed based on
the included gemspec files, combined with the additional_dependencies
field.

* Add pins for CI 'install Ruby' action

* Update setup-ruby pin

* Tweak version parsing

* Tweak env vars

---------

Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2025-11-03 19:12:25 +08:00
Jo 156f06977a Fix YAML with nested merge keys (#1020) 2025-11-03 15:36:40 +08:00
yihong c1e69ce1af Use temp dir in tests (#1017)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
2025-11-01 19:31:26 +08:00
renovate[bot] 0869a57bcb Update Rust crate assert_cmd to v2.1.1 (#1015)
* Update Rust crate assert_cmd to v2.1.1

* Fix

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2025-11-01 18:16:10 +08:00
renovate[bot] 23bf3e3784 Update pre-commit hook crate-ci/typos to v1.39.0 (#1014)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-01 18:05:15 +08:00
renovate[bot] 4c08dce4d5 Update dependency uv to v0.9.7 (#1008) 2025-11-01 12:10:00 +08:00
renovate[bot] ac4fccf323 Update Rust crate ctrlc to v3.5.1 (#1011) 2025-11-01 12:08:56 +08:00
renovate[bot] df6179017c Update dependency python to 3.14 (#1013) 2025-11-01 12:00:26 +08:00
renovate[bot] 4f6798d244 Update Rust crate ignore to v0.4.25 (#1012) 2025-11-01 11:59:23 +08:00
renovate[bot] 73bb025c08 Update Rust crate clap to v4.5.51 (#1009) 2025-11-01 11:58:22 +08:00
renovate[bot] 43999dcec0 Update Rust crate clap_complete to v4.5.60 (#1010) 2025-11-01 11:57:44 +08:00
renovate[bot] a69adc3791 Update GitHub Actions and speed up Windows CI (#1001)
* Update GitHub Actions

* Try to speed up windows CI

* Use `leafo/gh-actions-luarocks`

* Fix luarocks install failure

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2025-10-31 17:41:46 +08:00
Jo 6e69f990a9 Bump Rust toolchain to 1.91 (#1004)
* Bump Rust toolchain to 1.91

* Fix lint
2025-10-31 16:30:30 +08:00
Jo b8ea831189 Update project stability status (#1005)
Yeah, I’m taking on the stable responsibility!
2025-10-31 16:11:36 +08:00
renovate[bot] 189d89ab77 Update Rust crate indicatif to v0.18.2 (#1000)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-31 15:27:55 +08:00
renovate[bot] b1d9fc1e62 Update GitHub Actions (#1003)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-31 15:24:12 +08:00
renovate[bot] ad5c374032 Update Rust crate etcetera to 0.11.0 (#1002)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-31 15:23:06 +08:00
Copilot 03d17c054d Optimize hot paths: reduce allocations (#997)
* Initial plan

* Optimize hot paths: reduce allocations and add inline hints

- Eliminate duplicate tags_from_path calls in file filtering
- Avoid string allocation for lowercase extensions (fast path for already lowercase)
- Remove unnecessary String clones in environment variable setting
- Add inline hints to hot path functions (TagSet methods, filters, etc.)
- Use lookup table for is_text_char for faster binary detection

Co-authored-by: j178 <10510431+j178@users.noreply.github.com>

* Additional optimizations: avoid allocations in hot paths

- Optimize Partitions iterator to use as_os_str().len() instead of to_string_lossy().len()
- Optimize normalize_path on Windows to avoid intermediate String allocation when possible

Co-authored-by: j178 <10510431+j178@users.noreply.github.com>

* Revert incorrect filter.rs optimization

The previous change to combine filters was actually less efficient than the original.
The original code correctly filters by filename patterns first, then only calls
tags_from_path on files that pass the filename filter. My change was based on
a misunderstanding - there was no duplication of tags_from_path calls.

Keeping the other optimizations:
- Inline hints on filter functions
- String allocation optimizations in identify.rs
- Environment variable clone removal
- Lookup table for is_text_char
- Partitions iterator optimization
- normalize_path optimization

Co-authored-by: j178 <10510431+j178@users.noreply.github.com>

* Optimize IS_TEXT_CHAR to use 256 bits instead of 256 bytes

Changed from [bool; 256] (256 bytes) to [u32; 8] (32 bytes) using bitfield.
This reduces memory footprint by 8x while maintaining O(1) lookup performance.

The lookup now uses bit manipulation:
- table[idx / 32] gets the u32 containing the bit
- (1 << (idx % 32)) creates a mask for the specific bit
- Bitwise AND checks if the bit is set

Co-authored-by: j178 <10510431+j178@users.noreply.github.com>

* Lint

* .

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: j178 <10510431+j178@users.noreply.github.com>
2025-10-31 01:30:25 +08:00
Jo 5ae43ab61e Use lazy_regex for compile time regex checking (#996) 2025-10-30 21:26:28 +08:00
Jo 4a864b33db Minor tweaks (#994)
* Minor tweaks

* Fix snaps
2025-10-30 16:49:33 +08:00
Felix Blom aa6cd18cde Implement check-executables-have-shebangs as builtin-hook (#924)
* feat: Implement check-executables-have-shebangs hook

* Tweak

* Minor

* Tweak

* Minor

* feat: Implement check-executables-have-shebangs hook

* Fix paths

* Debug

* Debug

* Fix ls-files split

* Update docs

---------

Co-authored-by: Felix Blom <70511386+Felix-Blom@users.noreply.github.com>
Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2025-10-30 16:29:24 +08:00
Jo 8470e0424a Remove hotpath profiling (#991)
The profiling isn’t very useful right now - it’s way too sensitive to noise. What we really need is proper benchmarking that runs multiple times to filter out all that noise, like what you get with https://codspeed.io/ or https://bencher.dev/
2025-10-29 21:11:23 +08:00
Jo 59b82c7539 Warmup cache before run hotpath profiling 2025-10-29 17:12:33 +08:00
Jo a1b6d2821e Refactor bloat-check and hotpath workflow (#990)
* Refactor `bloat-check` and `hotpath` workflow

* Use faster profiling  profile

* Fix template injection issue

* Tweak
2025-10-29 17:00:38 +08:00
Jo e366cc2679 Fix hotpath profile comparison results path 2025-10-28 21:16:54 +08:00
Jo 83fa8234e1 Fix pr-commit reading result path (#986) 2025-10-28 18:08:06 +08:00
Jo 2fa29a7473 Fix pr-commit action (#985) 2025-10-28 17:50:23 +08:00
Louis Maddox 65a2fe22a6 Profile latency and allocations with hotpath (#956)
* perf(hotpath): profile prek run on its own repo

* Combine pr comments

* Fix path

---------

Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2025-10-28 17:41:47 +08:00
Copilot b524f38675 Document that .gitignore is respected by default during workspace discovery (#983)
* Initial plan

* Document that .gitignore is respected by default and add test

Co-authored-by: j178 <10510431+j178@users.noreply.github.com>

* Lint

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: j178 <10510431+j178@users.noreply.github.com>
2025-10-28 16:31:00 +08:00
Jo a18d363b7e Refactor identify using smallvec (#982)
```console
❯ hyperfine --warmup 3 'prek run -a trailing-whitespace' './target/release/prek run -a trailing-whitespace'
Benchmark 1: prek run -a trailing-whitespace
  Time (mean ± σ):      56.6 ms ±   7.8 ms    [User: 28.1 ms, System: 35.7 ms]
  Range (min … max):    48.0 ms …  73.0 ms    37 runs

Benchmark 2: ./target/release/prek run -a trailing-whitespace
  Time (mean ± σ):      51.0 ms ±   2.6 ms    [User: 28.1 ms, System: 35.3 ms]
  Range (min … max):    48.1 ms …  61.5 ms    46 runs

Summary
  ./target/release/prek run -a trailing-whitespace ran
    1.11 ± 0.16 times faster than prek run -a trailing-whitespace
```
2025-10-28 16:16:31 +08:00
my1e5 a9f9166b74 Add attrs to "who is using prek" (#981) 2025-10-28 11:27:04 +08:00
Jo 8dee1b5b8c Treat every file as executable to keep compatibility with pre-commit (#980) 2025-10-28 06:30:17 +08:00
Jo 15ef28aee9 Bump version to 0.2.12 (#978) v0.2.12 2025-10-27 20:11:46 +08:00
yihong b533e785c8 Fix local relative path in try-repo (#975)
* fix: try-repo can use relative path

Signed-off-by: yihong0618 <zouzou0208@gmail.com>

* fix: clippy warnings

Signed-off-by: yihong0618 <zouzou0208@gmail.com>

* Tweak

* Absolute path in init_repo

* Simplify fix

---------

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2025-10-27 19:55:56 +08:00
Jo ab6bb6aa64 Add a warning for unimplemented hooks (#976) 2025-10-27 17:43:12 +08:00
Jo 476d84cf00 Fix PREK_UV_SOURCE list indentation (#977) 2025-10-27 17:34:12 +08:00
Jo b6c6ba8461 Fail windows CI when an error occured (#971)
* Fail windows CI when an error occured

* Fix tests
2025-10-26 19:04:02 +08:00
Jo 473ca4a188 Update language support status (#970)
* Update language support status

* Tweak
2025-10-26 18:25:43 +08:00
Jo 76093daa26 Fix compatibility with older luarocks (#967) 2025-10-26 15:39:05 +08:00
Steven Taylor 7161581362 Allow using system trusted store by PREK_NATIVE_TLS (#959) 2025-10-26 03:56:02 +08:00
Jo a25ecfd6d6 Update README 2025-10-25 21:06:16 +08:00
Jo f36d12df44 Do not check for script subprocess status (#964) 2025-10-25 01:24:32 +08:00