fix(provider): use encoding settings in config by bearomorphism · Pull Request #1857 · commitizen-tools/commitizen
Pull request overview
Updates file-based version providers to respect the configured encoding when reading version files, addressing Windows decode errors for UTF-8 pyproject.toml and other non-ASCII content (Fixes #1636).
Changes:
- Add
FileProvider._get_encoding()and use it forread_text(...)inJsonProviderandTomlProvider. - Add provider tests and UTF-8 fixture data covering JSON/TOML reads with non-ASCII content.
- Add new test data files for composer.json and pyproject.toml encoding scenarios.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
commitizen/providers/base_provider.py |
Reads JSON/TOML using config.settings["encoding"] via _get_encoding() |
tests/providers/test_base_provider.py |
Adds tests validating providers can read UTF-8 files with non-ASCII content |
tests/data/encoding_test_pyproject.toml |
UTF-8 TOML fixture with non-ASCII strings to reproduce/guard the bug |
tests/data/encoding_test_composer.json |
UTF-8 JSON fixture with non-ASCII strings to reproduce/guard the bug |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.