Repository navigation
fix(providers): write files with the line ending from git core.eol - #2128
Merged
woile merged 1 commit intoNov 24, 2026
Merged
Conversation
Version providers wrote pyproject.toml, uv.lock, Cargo.lock, package.json and the other files they update with Path.write_text(), which uses the platform line ending. version_files and the changelog are written with smart_open(), which follows `git config core.eol`. On Windows with core.eol=lf, cz bump rewrote pyproject.toml with CRLF, while version_files and CHANGELOG.md kept LF. Write the provider files with smart_open() too. When core.eol is not set, the result is the same as before (os.linesep). Assisted By: AI
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2128 +/- ##
=======================================
Coverage 98.29% 98.29%
=======================================
Files 61 61
Lines 2870 2874 +4
=======================================
+ Hits 2821 2825 +4
Misses 49 49 ☔ View full report in Codecov by Harness. |
woile
approved these changes
Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Version providers write their files with
Path.write_text(), so they always use the platform line ending. The other files thatcz bumpwrites (version_files, the changelog, JSON/YAML config) go throughsmart_open()and followgit config core.eol(#493).On Windows with
core.eol=lf,cz bumpwith thepep621provider rewrites all ofpyproject.tomlwith CRLF, whileversion_filesandCHANGELOG.mdstay LF.uv.lock,Cargo.lock,package.json,package-lock.jsonandcomposer.jsonhave the same problem.This PR adds
FileProvider._write_text(), which usessmart_open(), and uses it for all provider writes. Ifcore.eolis not set, the output does not change.Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code
Assisted By: AI
Code Changes
uv run poe alllocally to ensure this change passes linter check and tests (I ran pytest, ruff and mypy separately)Expected Behavior
Provider files use the line ending from
git config core.eol, likeversion_filesand the changelog.Steps to Test This Pull Request
Run
pytest tests/providers/test_base_provider.py -k core_eol. The new test covers the six providers withcore.eolset tolfandcrlf. Without the fix, thelfcases fail on Windows.Manual check on Windows: in a repository with
git config core.eol lfandversion_provider = "pep621", runcz bump. Before the fix,git show --stat HEADshows every line ofpyproject.tomlas changed. After the fix, only the version line changes.Additional Context
Tested on Windows 10 with Python 3.14. The full suite passes, except for 10 tests that also fail on
masteron this machine (nogpg, hook runner not onPATH, twofile_regressionsnapshot names). Not tested on Linux or macOS.