From 426775fe5d5863ffb3ff5e7b66c892b208b9b6bf Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Singh Date: Sat, 15 Aug 2026 17:45:13 +0530 Subject: [PATCH 1/2] test: handle CRLF in stale identity guard --- rules/ast-grep/stale-identity.test.ts | 32 ++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/rules/ast-grep/stale-identity.test.ts b/rules/ast-grep/stale-identity.test.ts index 5a8297f761..e0875af6b6 100644 --- a/rules/ast-grep/stale-identity.test.ts +++ b/rules/ast-grep/stale-identity.test.ts @@ -14,7 +14,28 @@ const allowedLegacyCleanupMatches = new Set([ `packages/sdk-python/tests/test_build.py:"${legacyDistributionName}-0.1.0.tar.gz",`, ]); +const findUnexpectedMatches = (stdout: string): string[] => + stdout + .trim() + .split(/\r?\n/u) + .filter(Boolean) + .flatMap((match) => { + const parsed = /^(?[^:]+):\d+:(?.*)$/u.exec(match)?.groups; + if (!parsed?.file || parsed.contents === undefined) return [match]; + const identity = `${parsed.file}:${parsed.contents.trim()}`; + return allowedLegacyCleanupMatches.has(identity) ? [] : [match]; + }); + describe("Retired package identities", () => { + it("accepts exact legacy cleanup matches with CRLF line endings", () => { + const output = [ + `packages/sdk-python/scripts/build.py:18: "${legacyDistributionName}-*.whl",`, + `packages/sdk-python/tests/test_build.py:13: "${legacyDistributionName}-0.1.0.tar.gz",`, + ].join("\r\n"); + + expect(findUnexpectedMatches(output)).toEqual([]); + }); + it("does not reintroduce a Stagehand v4 package or test identity", async () => { const pattern = ["stagehand", "[-_]v4"].join(""); let stdout = ""; @@ -27,16 +48,7 @@ describe("Retired package identities", () => { if (grepError.code !== 1) throw error; stdout = grepError.stdout ?? ""; } - const unexpected = stdout - .trim() - .split("\n") - .filter(Boolean) - .flatMap((match) => { - const parsed = /^(?[^:]+):\d+:(?.*)$/u.exec(match)?.groups; - if (!parsed?.file || parsed.contents === undefined) return [match]; - const identity = `${parsed.file}:${parsed.contents.trim()}`; - return allowedLegacyCleanupMatches.has(identity) ? [] : [match]; - }); + const unexpected = findUnexpectedMatches(stdout); expect( unexpected, From 36a4c3fee37cfba3b6e103fa2bc018376bf9a22d Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Singh Date: Sat, 15 Aug 2026 17:51:03 +0530 Subject: [PATCH 2/2] test: document CRLF grep parsing --- rules/ast-grep/stale-identity.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/rules/ast-grep/stale-identity.test.ts b/rules/ast-grep/stale-identity.test.ts index e0875af6b6..69ea80d2e0 100644 --- a/rules/ast-grep/stale-identity.test.ts +++ b/rules/ast-grep/stale-identity.test.ts @@ -17,6 +17,7 @@ const allowedLegacyCleanupMatches = new Set([ const findUnexpectedMatches = (stdout: string): string[] => stdout .trim() + // Windows git writes CRLF; retaining the carriage return breaks the anchored parser below. .split(/\r?\n/u) .filter(Boolean) .flatMap((match) => {