Add prek util yaml-to-toml to convert .pre-commit-config.yaml to prek.toml#1584
Add prek util yaml-to-toml to convert .pre-commit-config.yaml to prek.toml#1584
prek util yaml-to-toml to convert .pre-commit-config.yaml to prek.toml#1584Conversation
prek util yaml-to-toml to convert .pre-commit-config.yaml to prek.toml
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1584 +/- ##
==========================================
+ Coverage 91.58% 91.65% +0.07%
==========================================
Files 92 93 +1
Lines 18136 18280 +144
==========================================
+ Hits 16609 16755 +146
+ Misses 1527 1525 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📦 Cargo Bloat ComparisonBinary size change: +0.42% (23.6 MiB → 23.7 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
There was a problem hiding this comment.
Pull request overview
This PR adds a new prek util yaml-to-toml command to convert .pre-commit-config.yaml files to the native prek.toml format. The conversion reads YAML configuration files, validates them, and outputs properly formatted TOML files with support for custom output paths and force-overwrite functionality.
Changes:
- Added new CLI command
prek util yaml-to-tomlwith input file argument,--outputand--forceoptions - Implemented YAML-to-TOML conversion logic using serde_saphyr for YAML parsing and toml_edit for TOML generation
- Added comprehensive integration tests covering basic conversion, overwrite protection, and invalid config handling
- Updated documentation to reference the new conversion utility
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
crates/prek/src/cli/yaml_to_toml.rs |
New file implementing the yaml-to-toml conversion command with file I/O, validation, and TOML generation logic |
crates/prek/src/cli/mod.rs |
Added YamlToTomlArgs struct and YamlToToml variant to UtilCommand enum, plus Debug derive on ExitStatus |
crates/prek/src/main.rs |
Integrated the yaml-to-toml command handler into the main command dispatcher |
crates/prek/src/config.rs |
Added accessor methods (patterns, regex_pattern, glob_patterns) to FilePattern types |
crates/prek/tests/yaml_to_toml.rs |
New integration test file with tests for default output, overwrite protection, and invalid config handling |
docs/configuration.md |
Added tip box recommending the new yaml-to-toml command for converting from YAML to TOML format |
docs/cli.md |
Auto-generated documentation for the new yaml-to-toml command with all options and arguments |
crates/prek/Cargo.toml |
Added "display" feature to toml dependency for better error formatting |
Cargo.toml |
Workspace-level addition of "display" feature to toml dependency |
No description provided.