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

223 Commits

Author SHA1 Message Date
joshuamarkovic
59230a7a72 Support orphan projects (#1129)
* Add deduplicate feature

# Conflicts:
#	src/cli/run/filter.rs

* Linting

* Linting

* Fix failed test

* Fix failed test

* More testing

* Revert "More testing"

This reverts commit 40304335c49d27f7024703da4f3ac4d775af52f7.

* Linting

* Support orphan projects

* Support orphan projects

* Fix filter

* Add a failing test

* "orphan" is an static attribute, always in effect

---------

Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2025-11-27 13:47:41 +08:00
Jo
dfb5a1c787 Close stdin for hook subcommands (#1155)
* Close stdin for hook subcommands

* Add tests
2025-11-26 17:04:16 +08:00
Jo
6dda4aa9f6 Do not dim the hook output (#1126)
* Do not dim the hook output

* Update snapshots
2025-11-20 19:16:55 +08:00
Jo
ec74c968ef Do not recurse into submodules during workspace discovery (#1121)
* .

* Do not recurse into submodules during workspace discovery
2025-11-19 20:02:11 +08:00
Jo
3e88436974 Add support repo: builtin (#1118)
* Add support `repo: builtin`

* Add docs

* Fixes

* Skip install for builtin hooks
2025-11-19 17:29:14 +08:00
Jo
683ad1f786 Revert back to serde_yaml again (#1112) 2025-11-18 22:46:32 +08:00
Jo
aed7e555d0 Restore using serde_yaml in check-yaml hook (#1106)
* Fix check-yaml: do not try to parse !!binary scalar into UTF-8 string

* Restore using `serde_yaml` in `check-yaml` hook

* Update snaps
2025-11-18 17:25:52 +08:00
Jo
bdaab388cc Do not require a project in prek init-template-dir (#1109)
* Do not require a project in `prek init-template-dir`

* Add test

* Discover project too
2025-11-18 16:47:44 +08:00
Jo
ce8faf7ea5 Add some more error context (#1097) 2025-11-17 18:30:05 +08:00
Jo
236967f63f Warn unexpected keys in repo and hook level (#1096) 2025-11-17 18:10:37 +08:00
Jo
abd6ed428d Tweak config parsing error message (#1094)
* Tweak config parsing error message

* Move code around
2025-11-17 16:24:11 +08:00
Jo
f38fe38329 Fix prek init-template-dir fails in non-git repo (#1093) 2025-11-17 15:25:53 +08:00
Jo
0dd2fcc9b2 Replace serde-yaml with serde_saphyr (#1087)
* .

# Conflicts:
#	Cargo.lock
#	Cargo.toml

* .

* .

* Replace `serde-yaml` with `serde_saphyr`

* Fix sanps

* Fix snaps
2025-11-16 15:58:39 +08:00
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