zjncs opened a new pull request, #5618:
URL: https://github.com/apache/rocketmq-dashboard/pull/5618
Closes #5617
## Problem
`cataloggen -check` compared the on-disk generated catalog byte-for-byte.
`go/format` always emits LF, but a Git for Windows checkout with the
**installer-default `core.autocrlf=true`** (and no `.gitattributes` in the
repo) smudges the file to CRLF — so the freshness gate is permanently red on
default Windows checkouts and `catalog-generate` needlessly rewrites the file
with flipped EOLs. Demonstrated on unmodified master: `-check` exits 1 with "is
stale" while the working-tree file and the generated output are
**byte-identical after EOL normalization** (42516 bytes/770 CRLF lines vs 41746
bytes/LF). The digest is EOL-independent; only the verify comparison is broken.
## Fix
Strip CR from CRLF pairs on both sides before comparing:
```go
if !bytes.Equal(normalizeEOL(actual), normalizeEOL(expected)) { ... }
```
## Verification
- New `verify_test.go` with two cases:
**`TestCheckToleratesCRLFWorkingTree`** (generates, rewrites the output with
CRLF to simulate the git smudge, runs `-check`, expects nil) — **FAILS on
master** ("is stale"), **PASSES with this change**;
**`TestCheckStillDetectsRealStaleness`** (corrupts a version token, expects the
stale error) — passes both before and after, proving the tolerance is not
vacuous
- Mutation check: stashing only the `main.go` change makes the tolerance
test fail again; restoring it passes (`-count=1` throughout)
- Regression: full `./internal/catalog/...` suite green
## Collision note
Same file as our open #5614 (single-file shadowing fix) but a different
function — #5614 touches the read branch at ~302-322, this change touches
`verify` at ~824-833; disjoint regions, trivial rebase either way. No foreign
PR touches the file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]