From a570132c9c1881da72691e6508a40b1d000935f0 Mon Sep 17 00:00:00 2001 From: Karstein Phobic Nyvold Kvistad Date: Sun, 26 Apr 2026 01:12:43 +0200 Subject: [PATCH] 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. --- src/server.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/server.ts b/src/server.ts index 79852b5..4ba8729 100644 --- a/src/server.ts +++ b/src/server.ts @@ -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 {