Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1271 +/- ##
========================================
Coverage 91.57% 91.57%
========================================
Files 92 92
Lines 17912 18122 +210
========================================
+ Hits 16403 16596 +193
- Misses 1509 1526 +17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📦 Cargo Bloat ComparisonBinary size change: +1.72% (23.2 MiB → 23.6 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
e7f23ae to
ac9aae2
Compare
ba41b8f to
9250c04
Compare
|
@j178 if |
Similar question here. Will this be an alternative to |
|
@ulgens The description is 'Closes #593', it's the former. (Also as you can see clearly from: Regarding the name, my 2p would be that |
|
@OJFord Oh, thank you. Checking it again now, it seems clear but I was confused at the time. |
|
But what about |
b51aab5 to
a95d7a7
Compare
f7a7700 to
20bdc34
Compare
There was a problem hiding this comment.
Pull request overview
Adds first-class support for a TOML-based configuration file (prek.toml) alongside existing .pre-commit-config.yaml configs, including updated workspace discovery, CLI behavior, and documentation.
Changes:
- Add TOML config loading and recognize
prek.toml(with defined filename precedence). - Update CLI commands (
sample-config,try-repo,auto-update) to generate/read/update TOML configs. - Refresh docs and integration/unit snapshots to cover TOML + new messaging.
Reviewed changes
Copilot reviewed 36 out of 38 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/configuration.md | Documents prek.toml, precedence rules, and TOML/YAML examples. |
| docs/cli.md | Updates CLI reference to include sample-config --format. |
| crates/prek/tests/workspace.rs | Updates workspace discovery snapshots/error messaging for TOML support. |
| crates/prek/tests/validate.rs | Uses renamed consts for YAML config filename. |
| crates/prek/tests/try_repo.rs | Updates try-repo snapshots for generated prek.toml output. |
| crates/prek/tests/sample_config.rs | Adds coverage for TOML sample config output and --format. |
| crates/prek/tests/run.rs | Adds/updates tests for precedence and running with prek.toml. |
| crates/prek/tests/meta_hooks.rs | Updates tests to use renamed YAML config constant. |
| crates/prek/tests/list.rs | Updates “no config found” snapshot for TOML awareness. |
| crates/prek/tests/languages/swift.rs | Renames manifest const usage in tests. |
| crates/prek/tests/languages/script.rs | Renames YAML config const usage in tests. |
| crates/prek/tests/languages/python.rs | Renames manifest const usage in tests. |
| crates/prek/tests/languages/golang.rs | Renames config/manifest const usage in tests. |
| crates/prek/tests/install.rs | Renames YAML config const usage in tests. |
| crates/prek/tests/hook_impl.rs | Updates snapshots and constants for TOML-aware discovery. |
| crates/prek/tests/common/mod.rs | Updates workspace helpers to write YAML config via new const. |
| crates/prek/tests/cache.rs | Updates tracked-config filename constants. |
| crates/prek/tests/builtin_hooks.rs | Updates YAML config constant usage in tests. |
| crates/prek/tests/auto_update.rs | Adds TOML auto-update coverage (including comment preservation). |
| crates/prek/src/workspace.rs | Adds config filename precedence, TOML discovery, and updated errors. |
| crates/prek/src/snapshots/prek__config__tests__read_yaml_config.snap | New snapshot for YAML config parsing test naming. |
| crates/prek/src/snapshots/prek__config__tests__read_toml_config.snap | New snapshot covering TOML config parsing. |
| crates/prek/src/snapshots/prek__config__tests__meta_hooks-5.snap | Updates meta-hooks snapshot to include prek.toml. |
| crates/prek/src/main.rs | Routes cache dir output to “important” stdout; wires new sample-config args. |
| crates/prek/src/hooks/meta_hooks.rs | Expands meta-hook config file matching to include prek.toml. |
| crates/prek/src/hook.rs | Renames manifest const and updates related tests. |
| crates/prek/src/config.rs | Adds TOML parsing path + error variant; adds TOML parsing tests/snapshots. |
| crates/prek/src/cli/try_repo.rs | Generates a TOML config for try-repo via toml_edit. |
| crates/prek/src/cli/sample_config.rs | Adds TOML sample config + format selection + improved file creation. |
| crates/prek/src/cli/mod.rs | Adds SampleConfigFormat/--format and new -f target handling. |
| crates/prek/src/cli/install.rs | Uses unified CONFIG_FILENAMES fallback list. |
| crates/prek/src/cli/hook_impl.rs | Updates missing-config error matching for renamed variant. |
| crates/prek/src/cli/cache_gc.rs | Updates handling of config “not found” after removing NotFound variant. |
| crates/prek/src/cli/auto_update.rs | Adds TOML rewrite path using toml_edit and keeps YAML behavior. |
| crates/prek/Cargo.toml | Adds toml_edit dependency. |
| crates/prek-consts/src/lib.rs | Introduces PREK_TOML, renamed constants, and CONFIG_FILENAMES. |
| Cargo.toml | Adds workspace dependency for toml_edit. |
| Cargo.lock | Locks toml_edit and transitive deps. |
| static SAMPLE_CONFIG_TOML: &str = indoc::indoc! {r#" | ||
| #:schema: https://json.schemastore.org/prek.json | ||
| # Configuration file for `prek`, a git hook framework written in Rust. | ||
| # See https://prek.j178.dev for more information. | ||
|
|
||
| [[repos]] | ||
| repo = "builtin" | ||
| hooks = [ | ||
| { id = "trailing-whitespace" }, | ||
| { id = "end-of-file-fixer" }, | ||
| { id = "check-added-large-files" }, | ||
| ]"#}; |
There was a problem hiding this comment.
SAMPLE_CONFIG_TOML currently ends at the closing ] without a trailing newline (the raw string terminator is on the same line). This makes the generated prek.toml file differ from typical POSIX text-file conventions and from the integration test snapshot expectations (which include a final newline). Consider adding a trailing newline to the TOML template and using write! vs writeln! consistently for stdout vs file output to avoid double blank lines.
Closes #593