0
0
Fork 0

classifyMcpMirrorChanges: ignore CRLF + whitespace-only diffs

Real bug surfaced on X33 (commit 6c23e38 on karstein.kvistad/x33,
reverted in 3e6f12f): the classifier called git diff --name-status
without any whitespace flags, so a fresh checkout that re-normalised
.st files from LF to CRLF (Windows working copy via Samba share)
showed every file as M. The orchestrator obediently bumped the
project to v1.0.1.0 with no actual code change, committed,
tagged, pushed -- a phantom release.

Fix: add --ignore-cr-at-eol AND -w to the git diff invocation so
the classifier only reports diffs with real content changes.

  --ignore-cr-at-eol  ignore the carriage-return at the end of line
                      when comparing lines (handles CRLF<->LF flips)
  -w                  ignore whitespace differences entirely
                      (defensive; protects against stray blank
                      lines and indent normalisation that aren't
                      real changes)

The companion fix is to also add a .gitattributes to each project
that pins the .st files to a stable line-ending in storage so the
phantom diffs don't appear in the first place. That's a per-project
artefact, shipped alongside the project repos (X33 + MCPTest2)
rather than this fork.
This commit is contained in:
Karstein Phobic Nyvold Kvistad 2026-04-26 01:12:43 +02:00
parent 3212996cf1
commit a570132c9c

View file

@ -261,8 +261,16 @@ function classifyMcpMirrorChanges(projectDir: string): ClassifyResult {
let raw = '';
try {
// --ignore-cr-at-eol: ignore CRLF<->LF normalisation noise. CODESYS
// lives on Windows, the share lives on Linux/Samba, and git
// autocrlf settings can flip line endings on every checkout. Without
// this flag the classifier reported every .st file as M after a fresh
// checkout even though the content was identical, triggering a
// phantom release on X33 (commit 6c23e38, reverted in 3e6f12f).
// -w: also ignore whitespace-only changes (defensive; phantom releases
// shouldn't fire on a stray blank line either).
raw = execSync(
`git -C "${projectDir}" diff --name-status -M50% ${baseRef} -- mcp-mirror/`,
`git -C "${projectDir}" diff --name-status --ignore-cr-at-eol -w -M50% ${baseRef} -- mcp-mirror/`,
{ encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] }
);
} catch {