fix: parseAnatomy tolerates CRLF line endings (fixes #50)#51
Open
albertomenache wants to merge 1 commit into
Open
fix: parseAnatomy tolerates CRLF line endings (fixes #50)#51albertomenache wants to merge 1 commit into
albertomenache wants to merge 1 commit into
Conversation
With CRLF endings (e.g. git core.autocrlf=true rewriting .wolf/anatomy.md on checkout), every entry line ends in \r and the $-anchored entry regex matches nothing, so the post-write hook's parse-then-rewrite cycle drops every entry and truncates anatomy.md to an empty skeleton. Split on /\r?\n/ in both parseAnatomy copies; serializeAnatomy already writes LF, so one pass renormalizes a poisoned file.
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.
Fixes #50.
parseAnatomysplit on plain"\n", so with CRLF line endings (e.g. gitcore.autocrlf=truerewriting.wolf/anatomy.mdon checkout — a common Windows default) every entry line ends in\rand the $-anchored entry regex matches nothing. The post-write hook's parse→rewrite cycle then drops every entry, truncating anatomy.md to an empty skeleton ("Files: 1 tracked", sections kept, entries gone).This PR changes the split to
/\r?\n/in bothparseAnatomycopies (src/hooks/shared.tsandsrc/scanner/anatomy-scanner.ts).serializeAnatomyalready writes LF, so one pass renormalizes a poisoned file; no other behavior changes.Verified against the live failure: with the patched parser, driving the post-write hook on a CRLF-converted anatomy.md preserves 161/161 entries (pre-patch it collapsed to 1). Full repro steps in #50.