Repository navigation
fix: read the baseline and git history the same under any locale - #5
Merged
Merged
Conversation
With LANG unset, Ruby tags file and pipe input US-ASCII, so any non-ASCII byte broke hashira with an internal error (exit 70): - `--ratchet` / `--update-baseline`: JSON.parse could not transcode a baseline holding e.g. an em dash. The baseline is now read and written as UTF-8, so a write under `ruby -U` no longer transcodes it either. - Every run, when git's core.quotepath is off and the history names a non-ASCII file: splitting the git log raised. The log is read as bytes and churn matches paths byte for byte, since Dir tags the same names BINARY under that locale and UTF-8 under a UTF-8 one. readme_spec read README.md the same way; it now passes under that locale too, so bin/ci is green with LANG unset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PcDfzLuRgjoSnfPLrTaA4h
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.
When the locale isn't UTF-8 (
LANG/LC_ALLunset, as in many containers), Ruby tags file and pipe input as US-ASCII. Any non-ASCII byte then made hashira stop with an internal error (exit 70).What broke
--ratchet/--update-baselinewith a baseline holding non-ASCII text, e.g. an em dash in an acceptance reason. kimera'shashira_baseline.jsonhits this:Baseline#readdidJSON.parse(File.read(@path)), and JSON could not transcode the US-ASCII-tagged text.core.quotepathis off and the history names a non-ASCII file.GitLog#countssplit the US-ASCII-taggedgit logoutput and gotArgumentError: invalid byte sequence in US-ASCII.Changes
CI::Baselinereads and writes the baseline as UTF-8. The write was already correct under a plain non-UTF-8 locale. Withdefault_internalalso set (e.g.ruby -U), it transcoded UTF-8 to US-ASCII and raisedUndefinedConversionError. Now it can't.GitLogreadsgit logas bytes (binmode: true), andChurn#hitscompares paths byte for byte. Decoding git's output as UTF-8 would not be enough: under a US-ASCII localeDir[]returns non-ASCII paths as BINARY, andend_with?raises on UTF-8 vs BINARY. Comparing bytes matches the names under either locale.spec/readme_spec.rbreadREADME.mdthe same way and failed under that locale. It now reads it as UTF-8, so all ofbin/cipasses withLANGunset.Prism.parse_file, which reads bytes and defaults to UTF-8. The JSON and text reports print correctly under that locale. hashira has no config file.Tests
with_default_encodingsspec helper swapsEncoding.default_external/default_internaland restores both in anensure.core.quotepath=falseand a file namedcafé.rbgets churn 1 under both UTF-8 and US-ASCII.mainwith the errors above. Each change was also reverted alone (.b, the write encoding, the read encoding), and each revert fails its own spec.bin/cipasses withLANG=C.UTF-8and withLANG/LC_ALLunset: rubocop, rubocop-kata doctor, 502 examples, the gate, andRatchet OK: 16 edges, 0 findings, unchanged.kimera ci --since origin/main: 5 mutants on changed lines, all killed.lib/café/menú.rbandcore.quotepath=falseunder an unsetLANG:--ratchet,--update-baselineand a plain run all exit 0 (before: 70), and churn countscafé/menú.rb.Not in this PR
With git's default
core.quotepath=true,git logquotes non-ASCII paths ("lib/caf\303\251.rb"). Churn then never matches those files and reports 0 under any locale. Passing-c core.quotePath=falseinGitLog::LOGwould fix it. It's a separate bug, so I left it out.🤖 Generated with Claude Code
https://claude.ai/code/session_01PcDfzLuRgjoSnfPLrTaA4h
Generated by Claude Code