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

210 Commits

Author SHA1 Message Date
Jo e672f83235 Support language: unsupported and language: unsupported_script introduced in pre-commit v4.4 (#1073)
* Support `language: unsupported` and `language: unsupported_script` introduced in pre-commit v4.4

Honestly, I have no idea why `system` and `script` got deprecated or what we're supposed to use instead. I probably won't deprecate them in prek.

* Fix lint
2025-11-14 15:53:21 +08:00
Jo cc6fb514e3 Fix --files argument - files referencing other projects aren’t being filtered (#1064) 2025-11-14 13:35:52 +08:00
Jo 1032757a83 Add a hint to use --refresh when no configuration found (#1046) 2025-11-08 18:45:51 +08:00
Jo 2a77fd57a5 Add a hint to install when running inside a sub-project (#1045)
* Add a hint to install when running inside a sub-project

* Fix snap
2025-11-07 18:28:56 +08:00
nate nowack 6b72fdf5d5 Fix grammar in install message: use past tense 'moved' (#1041)
The install command actually moves the existing hook file automatically,
so the message should say 'moved it to' rather than 'move it to' (which
reads like an instruction to the user).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-07 11:00:44 +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
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
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
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
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
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 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
Les Freire ed3f357f85 Support language: lua hooks (#954)
* Add Lua language support

Refactor Lua integration: streamline async functions and improve rockspec file handling

Add Lua and LuaRocks installation steps to CI workflow

Add MSVC development command to CI workflow

Update CI workflow to specify Windows-only dependencies for MSVC and Lua installations

Update CI workflow to use official Lua and LuaRocks GitHub actions

Update CI workflow to specify Windows-only dependencies for Lua and LuaRocks installations

Update CI workflow to use PowerShell for Cargo test execution and improve command formatting

Add platform-specific command snapshots for Lua tests

Enhance the Lua test environment by adding separate command snapshots for Windows and non-Windows platforms. This ensures accurate output handling based on the operating system, improving test reliability and clarity.

Update CI workflow to use specific versions of Lua and LuaRocks actions

Refactor Lua dependency installation and update test cases

Refactor Lua command execution to streamline environment path handling

Fix dependencies installing

Fix remote repo hook

* Add lua remote_hook test

* Tweaks

---------

Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2025-10-24 19:36:38 +08:00
Jo 697b101b6d Improve styling for stashing error message (#953) 2025-10-22 16:34:08 +08:00
Jo a4e8f20c8d Support language_version: system (#949)
* .

* Support `language_version: system`

* Fix python downloads
2025-10-21 20:23:32 +08:00
Les Freire 4a1e907150 Implement no-commit-to-branch as builtin hook (#930)
* feat: (no-commit-to-branch) implement builtin hook

Enhance error handling

Refactor no_commit_to_branch function to simplify branch protection logic and improve error handling

Simplified current branch parsing and improved error messages for better clarity.

Refactor no_commit_to_branch hook to enhance argument handling and branch protection logic.

Consistent with pre-commit implementation and additional testing

Simplify the logic of check_protected

fix logic error

* Delete redundant comments

* Tweak

---------

Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2025-10-20 13:27:42 +08:00
Louis Maddox bbdac782d6 Implement check-xml as builtin hook (#894)
Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2025-10-17 17:12:15 +08:00
Jo 054e1fbb00 Error out if not projects found (#913) 2025-10-17 16:16:05 +08:00
Aditya Yadav 67d956e8a0 Add --fail-fast CLI flag to stop after first hook failure (#908)
* Add --fail-fast CLI flag to stop after first hook failure

- Add fail_fast field to RunArgs struct with CLI flag support
- Fix in hook_impl.rs where fail_fast was hardcoded to false
- Update run() and run_hooks() to accept and propagate fail_fast parameter
- CLI flag overrides config file setting (enables fail-fast mode)
- Ensure try-repo and main entry point pass fail_fast correctly

* Update test snapshots for --fail-fast flag

* Add CLI flag test for --fail-fast

* Fix trailing whitespace in test comment
2025-10-17 11:07:27 +08:00
Louis Maddox ede9d4b760 Implement check-merge-conflict as builtin hook (#885)
* feat(check-merge-conflict): implement builtin hook

* fix: reuse core git helper fn
2025-10-17 01:27:17 +08:00
Jo 20c24af285 Fix golang hook install local dependencies (#902) 2025-10-16 18:34:52 +08:00
Louis Maddox 6df836bcf0 Implement detect-private-key as builtin hook (#893)
* feat(detect-private-key): implement builtin hook

* Reduce unnecessary tests

---------

Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2025-10-16 15:55:26 +08:00
Louis Maddox ad6fbf7703 Implement check-symlinks as builtin hook (#895) 2025-10-15 23:37:24 +08:00
yihong 373b0f1607 Support YAML merge keys in .pre-commit-config.yaml (#871)
* fix: close issue #870 by merge and ignore the config

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

* Tweak

---------

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2025-10-14 11:25:37 +08:00
Jo 442d88d7d7 Use relative path with --cd in the generated hook script (#868)
* Use relative path with `--cd` in generated hook script

Use a relative path with `--cd` in the generated hook script to avoid switching to the original worktree.

Also, unset `GIT_DIR` in the hook script so git doesn’t treat the current directory (after the cd) as the git root.

* Fix snapshots

* Add tests
2025-10-13 21:42:02 +08:00
Benjamin Bannier ee7110b49b Fix autoupdate rev rendering for "float-like" version numbers (#867)
A version number could look like a float, e.g., 0.49 is a valid version
number. Serde YAML serialization already renders such version numbers in
quotes so types match the expectation. When doing an autoupdate we were
explicitly adding more quotes if they were present in the input. This
could have caused incorrect quoting if existing quoting clashed with
serde's quoting style, e.g., if `"` where used but serde defaulted to
quoting with `'`.

This patch removes any extra quoting here and fully defers to serde.

Closes #866.
2025-10-11 18:27:48 +08:00
Luiz Otavio Vilas Boas Oliveira 74cb495dea Implement prek try-repo (#797)
* Add try_repo logic and tests (WIP)

* Remove unnecessary mut

* Fix clippy issues

* Add unit test

* Update snapshots

* Update docs

* Update unit test

* WIP

* Update snapshots

* Lint

* Add extra filters to try_repo tests

* Lint

* Update unit tests

* Apply Josh's suggestions

* Fix arg name

* .

* Fix

* Fix

* Generate

* Fix snapshot

* Improve coverage

---------

Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2025-10-10 21:11:31 +08:00
Jo 9a4fb2be88 Ignore config error if the directory is skipped (#860)
* Ignore config error if the directory is skipped

* Add test
2025-10-09 19:58:31 +08:00
Jo 7ccee511f1 Add fallback mechanism for prek executable in git hooks (#850)
* Add fallback mechanism for prek executable in git hooks

* Fix
2025-10-08 02:52:09 +08:00
Jo 7a17c4b677 Improve install message when installing for a sub-project (#847)
* Improve install message when installing for a sub-project

* Fix tests
2025-10-07 16:47:42 +08:00
Jo 0dd84cd620 Improve language version download tests (#832) 2025-10-01 22:31:57 +08:00
Nyakku Shigure 88b1e796cd Allow run --files with zero args (#831) 2025-10-01 21:22:54 +08:00
Nyakku Shigure 7b8cb627bd Support pass multiple files like prek run --files a b c d (#828) 2025-10-01 19:32:27 +08:00
Jo 59960410fa Add support for .prekignore to ignore directories from project discovery (#826) 2025-10-01 18:15:10 +08:00
Jo 0adb26401d Add a global --log-file flag to specify the log file path (#817) 2025-09-29 16:30:48 +08:00
Jo 1c425e43ad Implement hook health check (#798)
* Implement hook health check

* Add node health check

* Add health check for pygrep

* Add test
2025-09-29 10:47:14 +08:00
Jo d7c39b5733 Show error message in quiet mode (#807)
* Show error message in quiet mode

In quiet mode (`-q`), error messages will still be printed.
In silent mode (`-qq`), nothing gets printed.

* Generate cli doc

* Add test
2025-09-28 13:50:16 +08:00
Jo d0f7c4d6b0 Add --dry-run to prek auto-update (#806) 2025-09-28 12:06:44 +08:00
Jo df852e914a Add a hint when hooks failed in CI (#800)
* .

* Add a hint when hooks failed in CI

* Fix tests
2025-09-26 13:27:55 +08:00
Jo 04bb76fcb4 Add prek cache dir, move prek gc and prek clean under prek cache (#795)
`prek gc` and `prek clean` are still available but hidden.
2025-09-25 13:36:41 +08:00
Jo 63fc5fc8da Improve arg parsing for builtin hooks (#789)
* Improve arg parsing for builtin hooks

* Fix tests
2025-09-24 13:36:30 +08:00
Jo 4c0eb8337c Remove some unused code (#763) 2025-09-19 23:54:13 +08:00
Jo 9298e0b49e Bump pre-commit-hooks in sample-config to v6.0.0 (#761) 2025-09-19 23:36:15 +08:00
Jo e78b46cc46 Bump rust toolchain to 1.90 (#760) 2025-09-19 22:59:01 +08:00
Jo 022ef1824c auto-update: prefer tags that are most similar to the current version (#719)
* auto-update: prefer tags that are most similar to the current version

* Add test
2025-09-15 21:35:44 +08:00
Jo d7815f61ec Clean working tree of current workspace only (#747)
* .

* Clean working tree of current workspace only

* Fix write-tree

* Fix windows
2025-09-15 21:21:35 +08:00
Jo 6e6374dd13 Fix hook-impl don't run hooks when specified allow missing config (#716)
Closes #715
2025-09-11 16:46:07 +08:00
Kushagra Udai 4b89c003f2 Add built in byte-order-marker fixer (#700)
* Add built in byte-order-marker fixer

* fmt

* feedback

* fmt
2025-09-11 10:39:42 +08:00