Skip to content

fix: Windows path separator leak and CRLF-inflated file sizes (#21) - #27

Merged
thorwhalen merged 2 commits into
mainfrom
fix/windows-path-separator-and-crlf-size-21
Sep 22, 2026
Merged

thorwhalen merged 2 commits into
mainfrom
fix/windows-path-separator-and-crlf-size-21

Conversation

@thorwhalen

Copy link
Copy Markdown
Owner

Summary

  • Display paths in opsward/cli.py::_relative_path and opsward/generate.py::_find_conftest now render via PurePath.as_posix() instead of str(Path), so misc\docs\... no longer leaks into printed CLI output or generated doc content on Windows.
  • .gitattributes gains * text=auto eol=lf so fixtures/templates always check out with LF, fixing reported byte sizes (a 37-byte stub was measuring 40 under a CRLF checkout).
  • Removes the six now-stale WINDOWS_CONTENT_DIFFS entries in tests/test_cli_parity.py — the test's own docstring says this is the correct outcome once CI: Windows tests failing (pre-existing, non-blocking) #21 is fixed ("the test fails with unexpected-match... delete the entry").

Both root causes and their fixes were already precisely spec'd in #21's own comment; this PR implements exactly that spec.

Closes #21

Test plan

  • pytest — 134 passed, 1 skipped (local venv, Python 3.12)
  • tests/test_cli_parity.py passes standalone
  • Verified _relative_path renders forward slashes given a POSIX Path
  • Hosted CI Windows matrix (this repo is public — watching gh pr checks) is the real verification of the Windows-specific half; I have no Windows box to test on directly

🤖 Generated with Claude Code

thorwhalen and others added 2 commits September 22, 2026 13:22
Display paths (`opsward/cli.py::_relative_path`, `opsward/generate.py::_find_conftest`)
now render via `PurePath.as_posix()` instead of `str(Path)`, so `misc\docs\...`
no longer leaks into printed CLI output or generated doc content on Windows.

`.gitattributes` gains `* text=auto eol=lf` so fixtures/templates always check
out with LF, fixing reported byte sizes (a 37-byte stub was measuring 40 under
a CRLF checkout).

Removes the six now-stale WINDOWS_CONTENT_DIFFS entries in
tests/test_cli_parity.py, which the test's own docstring flagged as the
correct outcome once #21 was fixed.

Closes #21

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…path form

These two check target_path -- a real filesystem Path used to actually write
the generated file -- via str(), which is a WindowsPath rendering backslashes
on Windows (correctly; that's how the file gets written). Switch the assertion
to .as_posix() so it checks the logical path instead of the OS rendering,
matching what test_testing_md_includes_conftest_when_present already does for
generated *content* (a real portability concern, fixed separately in this PR).

Found via the hosted Windows CI run on this PR -- issue #21 had named these two
tests as failing for the display-path bug, but they actually fail for this
unrelated reason (a test assertion issue, not a source bug).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@thorwhalen
thorwhalen merged commit f0ce2bd into main Sep 22, 2026
12 checks passed
@thorwhalen
thorwhalen deleted the fix/windows-path-separator-and-crlf-size-21 branch September 22, 2026 13:27
thorwhalen added a commit that referenced this pull request Sep 22, 2026
#27 fixed the CRLF-inflated sizes only for opsward's own fixtures (via
.gitattributes). Projects that opsward scans are still checked out with
CRLF on Windows (core.autocrlf=true is the Git for Windows default), so
the stub heuristics driven by DocSpec.size_bytes gave host-dependent
answers. Count bytes after normalizing CRLF to LF, with a regression test.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: Windows tests failing (pre-existing, non-blocking)

1 participant