fix(release): write the native version transform as exact UTF-8 LF bytes - #120
Merged
Conversation
`validate_git_version_transform` reconstructs the five-file version transform
from the base ref and compares every resulting byte with the candidate tag's
Git blobs. `set_native_version` produced those bytes with `Path.write_text`,
which opens the file in text mode: on Windows every `\n` becomes `\r\n`, and
two of the reads omitted `encoding=` so they decoded with the locale default.
The reconstruction therefore never matched an LF blob on Windows. All five
files were reported as differing, and `main` failed on windows-latest for
Python 3.11 and 3.12:
ValueError: native tag differs from the exact deterministic set-version
output: package.json, package-lock.json, src-tauri/Cargo.toml,
src-tauri/Cargo.lock, src-tauri/tauri.conf.json
Read and write the five sources as explicit UTF-8 bytes. The transform is now
byte-identical on every platform, which is what the comparison assumes.
The tests carried the same platform dependence, so make them exact too: the
fixture writes UTF-8 LF bytes, and each temporary repository sets
`core.autocrlf=false` so the committed blobs equal those bytes. Git for Windows
defaults that setting to `true` and would otherwise rewrite the blobs the
transform is compared against.
New test `test_set_native_version_writes_utf8_lf_bytes_on_every_platform` pins
the invariant directly, so a future text-mode write is caught on any runner
rather than only on Windows.
Tests: full suite 1027 passed. Ruff passed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
What
Make
set_native_versionproduce byte-identical output on every platform.Why
mainfailed onwindows-latestfor Python 3.11 and 3.12 after #115:validate_git_version_transformreconstructs the five-file transform from thebase ref and compares every byte with the candidate tag's Git blobs, which
store LF.
set_native_versionwrote those files withPath.write_text, whichopens in text mode and rewrites every
\nas\r\non Windows. Two reads alsoomitted
encoding=, so they decoded with the locale default. All five filestherefore differed.
test.ymlruns the Linux lane only for pull requests, sothe exact-head checks on #115 could not see it.
This is a portability defect, not a tag defect. The release workflow runs on
ubuntu-22.04, so no published release was affected — but a byte-exactnessguarantee should not depend on which platform evaluates it.
How
set_native_versionreads and writes all five sources as explicit UTF-8bytes, so the transform emits LF everywhere.
core.autocrlf=false. Git for Windows defaults that totrueand wouldotherwise rewrite the very blobs the transform is compared against.
test_set_native_version_writes_utf8_lf_bytes_on_every_platformpins theinvariant so a future text-mode write fails on any runner, not only Windows.
Tests
ruff check engine/ tests/ scripts/: passed.🤖 Generated with Claude Code