Introduce a typed shell option so hooks can opt into multiline shell-source execution without changing the default direct argv behavior. Shell adapters write entry content to temporary scripts and pass hook args and filenames through shell-specific argument conventions like "".
## Summary
- add `prek auto-update --exit-code` to return status 1 when updates are
available
- keep `--check` as an alias for `--dry-run --exit-code`
Closes#2001
Stacked on #1983.
Adds glob-based tag filters for `prek auto-update`:
- `--include-tag <pattern>` and `--exclude-tag <pattern>` apply to all
repositories.
- `--repo-include-tag <repo>=<pattern>` and `--repo-exclude-tag
<repo>=<pattern>` apply to a single repository.
Filters are applied before selecting the update candidate, with include
filters evaluated before exclude filters.
Closes#1972Closes#174
Adds `prek auto-update --exclude-repo <repo>` as an opt-out repository
filter.
The new flag can be repeated and is applied before repository fetches
are scheduled, so skipped repositories are not cloned or evaluated.
Closes#1972
Prefer stable Rust toolchains over newer nightly toolchains when
resolving system Rust for default requests. Nightly is still used when
it is the only matching candidate.
Closes#1970
## Summary
- hide `auto-update`'s `already up to date` output unless verbose mode
is enabled
- include the current rev in verbose `already up to date` messages
## Summary
- make `check-merge-conflict` detect conflict blocks contextually
instead of flagging any bare `=======`
- add support for diff3 ancestor markers (`|||||||`)
Closes#1924Closes#1523
## Summary
This takes a smaller approach than #1673.
Instead of mutating Git config during install, it lets `prek` ask Git
for the effective hooks directory and:
- honors repo-local (`git config --local`) `core.hooksPath`
- honors worktree-local (`git config --worktree`) `core.hooksPath`
- continues to refuse global/system `core.hooksPath` by default
- aligns `prek uninstall` with the same behavior
- updates the CLI reference and FAQ to document the behavior
This keeps the existing safety boundary for externally configured hook
locations while making linked worktrees and repo-owned hook directories
work without extra wrapper logic.
## Testing
- `cargo test -p prek --test install`
- `PREK_GENERATE=1 cargo test --bin prek
cli::_gen::generate_cli_reference -- --exact`
## Context
Closes#1672Closes#1673
---------
Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
## Summary
`auto-update` now validates existing `# frozen:` comments against the
commit pinned in `rev`.
If the frozen comment is stale:
- in normal update mode, `auto-update` updates it to a matching ref when
possible, or removes it if no ref points to the pinned commit
- in `--dry-run`, it only reports the mismatch and does not modify the
config file
- in `--check`, it behaves like `--dry-run` and exits with status 1 if
updates would be made
This keeps frozen comments consistent with pinned SHA revisions without
adding a separate command.
## Example
```console
❯ cargo run -- auto-update --check
warning: [https://github.com/crate-ci/typos] frozen ref `v1.0` does not match `1111111111111111111111111111111111111111`
--> .pre-commit-config.yaml:18:63
|
18 | rev: '1111111111111111111111111111111111111111' # frozen: v1.0
| ^^^^ `v1.0` could not be resolved
|
= note: pinned commit `1111111111111111111111111111111111111111` does not exist in the repo
```
Closes#1864
Hi, I thought I'd give a stab at dotnet support for prek. Not really an
amazing language for how it manages tools & its toolchain, so perhaps
some nastiness. Seems to work for `csharpier` at least for me.
There's some missing tests around the windows part of the code in the
coverage but I didn't want to get into messing with CI for windows
runners, maybe we can drop the powershell stuff if we make windows
people run in a bash type environment?
Not very versed in rust but hoping that even if stuff's bad there's a
bit of a start for someone better than I to have a stab at.
closes#48
---------
Co-authored-by: Thomas Carroll <thomas.carroll@kroll.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
## Description
Following the information provided in
[880](https://github.com/j178/prek/issues/880). This is an
implementation of the `pretty-format-json` hook.
The
[pretty-format-json](https://grep.app/search?f.path.pattern=.pre-commit-config.yaml&q=pretty-format-json)
has 1k grep.app hits. It's the final unimplemented hook used by
`airflow` as mentioned in [this
comment](https://github.com/j178/prek/issues/880#issuecomment-3405716137).
----
## Notes
- **Preserve JSON Order**
- Added the `preserve_order` feature to `serde_json`. This prevents
`serde` from automatically ordering JSON data, which is important for
comparisons with older implementations.
- This change does not appear to affect other tests/features.
- By default, `serde` uses a `BTreeMap` for `Object`. Enabling
`preserve_order` switches it to `IndexMap`.
- This keeps the sorting logic within the `sort-keys` argument.
- **Git-Style Diff with `similar`**
- Added the `similar` library to perform git-style diff checks.
- Binary size increase is minimal.
- Useful as a general utility and could be leveraged in other parts of
the project, maybe needed to be relocated?
- Added color highlighting to the diffs, improving readability compared
to original `pre-commit`.
```bash
cargo clean
cargo build --release
```
- Master branch: **8.49 MB**
- Feature branch: **8.55 MB**
- **+66,176 bytes** (**+0.74%**) increase from master to feature branch
_Q: why is my size so much smaller than both sizes mentioned
[here](https://github.com/j178/prek/pull/884#issuecomment-3406885242)?_
-----
### Performance
Ran these commands on the `airflow` repository:
```bash
# old
pre-commit run pretty-format-json --all-files --verbose
Format JSON files........................................................Passed
- hook id: pretty-format-json
- duration: 0.03s
# Old prek implementation (python)
prek run pretty-format-json --all-files --verbose
Format JSON files........................................................Passed
- hook id: pretty-format-json
- duration: 0.03s
# New implementation (rust)
prek run pretty-format-json --all-files --verbose
Format JSON files........................................................Passed
- hook id: pretty-format-json
- duration: 0.00s
```
## Output
Old pre-commit:
<img width="601" height="376" alt="image"
src="https://github.com/user-attachments/assets/f0553015-24cf-4d23-98e8-2759f912c9b3"
/>
New:
<img width="707" height="430" alt="image"
src="https://github.com/user-attachments/assets/fa7ce303-caa9-4139-9e77-6e58db5f0725"
/>
Where both would autofix to the same:
<img width="349" height="304" alt="image"
src="https://github.com/user-attachments/assets/67baf526-787b-4aa6-a0fe-7859a2a5fb8b"
/>
---------
Co-authored-by: Felix Blom <70511386+Felix-Blom@users.noreply.github.com>
Co-authored-by: Jo <10510431+j178@users.noreply.github.com>