1
0
mirror of https://github.com/j178/prek.git synced 2026-04-03 17:34:03 +02:00
Commit Graph

202 Commits

Author SHA1 Message Date
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
Jo
3d6f9f1d5a Fix trailing-whitespace & mixed-line-ending write file path (#708) 2025-09-10 23:46:27 +08:00
Jo
56bcab7337 Fix file path handling for meta hooks in workspace mode (#699) 2025-09-10 11:39:14 +08:00
Jo
736768b4f6 Support selectors in prek install/install-hooks/hook-impl (#683)
* .

* Support selectors in `prek install`

* Support `prek install-hooks` too

* Add tests
2025-09-09 23:39:41 +08:00
Aravindan M
62438bc9dc Fix Docker image and Go version test issues for portability (#692)
* Update docker_image.rs

* Update golang.rs

* Update tests/languages/golang.rs

* Fix clippy

---------

Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2025-09-09 22:36:05 +08:00
Jo
9eb3a23d74 Fix check_toml and check_yaml in workspace mode (#688)
* Fix `check_toml` and `check_yaml` in workspace mode

Fixes #686

* Add test
2025-09-09 22:22:56 +08:00
Jo
d65723522f Ignore two node flaky tests for now (#691) 2025-09-09 22:03:03 +08:00
Jo
bc1b423a94 Bring back .pre-commit-config.yml support (#676)
* Bring back `.pre-commit-config.yml` support

* Fix snaps
2025-09-08 19:39:46 +08:00
Jo
4cb4f7ca54 Add a warning to hook-impl when the script needs reinstall (#647)
* Add a warning to `hook-impl` when the script needs reinstall

* add hook type

* update snaps
2025-09-07 20:35:52 +08:00