mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-16 17:09:09 +00:00
Validated in the 2026-09-28 merge-batch: all 38 PRs of this wave boarded together on release/v3.8.51 (a58000c) — typecheck:core and open-sse typecheck clean, focused tests of the whole board 429/434 (the remaining reds belong to PRs held for rework or already fail on the tip), static gates green apart from file-size/docs-count reconciliation landed in the wave follow-up. Thank you @HouMinXi!
This commit is contained in:
@@ -0,0 +1 @@
|
||||
- **quality:** normalize symlinked worktree directories and report paths in new-code mode gates so macOS base violations match accurately (#14744).
|
||||
@@ -97,11 +97,25 @@ export function withBaseWorktree(sha, fn) {
|
||||
* `filePath` is made relative to `cwd` so HEAD and base reports share keys.
|
||||
*/
|
||||
export function perFileRuleCounts(report, rules, cwd) {
|
||||
let realCwd = cwd;
|
||||
try {
|
||||
realCwd = fs.realpathSync(cwd);
|
||||
} catch {
|
||||
/* fallback to cwd */
|
||||
}
|
||||
const counts = new Map();
|
||||
for (const entry of report || []) {
|
||||
const rel = path.isAbsolute(entry.filePath)
|
||||
? path.relative(cwd, entry.filePath).split(path.sep).join("/")
|
||||
: entry.filePath;
|
||||
let filePath = entry.filePath;
|
||||
if (path.isAbsolute(filePath)) {
|
||||
try {
|
||||
filePath = fs.realpathSync(filePath);
|
||||
} catch {
|
||||
/* fallback */
|
||||
}
|
||||
}
|
||||
const rel = path.isAbsolute(filePath)
|
||||
? path.relative(realCwd, filePath).split(path.sep).join("/")
|
||||
: filePath;
|
||||
let n = 0;
|
||||
for (const m of entry.messages || []) if (rules.has(m.ruleId)) n++;
|
||||
counts.set(rel, (counts.get(rel) || 0) + n);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
|
||||
import {
|
||||
@@ -127,3 +130,43 @@ test("newDeadSymbols reports only symbols that are new on HEAD, in touched files
|
||||
]);
|
||||
assert.deepEqual(newDeadSymbols(base, head, ["src/a.ts"]), []);
|
||||
});
|
||||
|
||||
test("perFileRuleCounts normalizes symlinked cwd so canonical paths match (#14744)", () => {
|
||||
const realBase = fs.realpathSync(os.tmpdir());
|
||||
const realDir = fs.mkdtempSync(path.join(realBase, "omni-test-real-"));
|
||||
const symDir = path.join(realBase, `omni-test-symlink-${Date.now()}-${Math.random().toString(36).slice(2)}`);
|
||||
fs.symlinkSync(realDir, symDir, "dir");
|
||||
|
||||
const report = [
|
||||
{
|
||||
filePath: path.join(realDir, "open-sse/executors/commandCode.ts"),
|
||||
messages: [{ ruleId: "complexity" }, { ruleId: "max-lines-per-function" }],
|
||||
},
|
||||
{
|
||||
filePath: "src/relative.ts",
|
||||
messages: [{ ruleId: "complexity" }],
|
||||
},
|
||||
];
|
||||
|
||||
try {
|
||||
const counts = perFileRuleCounts(report, new Set(["complexity", "max-lines-per-function"]), symDir);
|
||||
assert.equal(counts.size, 2);
|
||||
assert.equal(counts.get("open-sse/executors/commandCode.ts"), 2);
|
||||
assert.equal(counts.get("src/relative.ts"), 1);
|
||||
|
||||
// Fallback when cwd does not exist on disk
|
||||
const fallbackCounts = perFileRuleCounts(
|
||||
[{ filePath: "/nonexistent/repo/src/a.ts", messages: [{ ruleId: "complexity" }] }],
|
||||
new Set(["complexity"]),
|
||||
"/nonexistent/repo"
|
||||
);
|
||||
assert.equal(fallbackCounts.get("src/a.ts"), 1);
|
||||
} finally {
|
||||
try {
|
||||
fs.unlinkSync(symDir);
|
||||
} catch {}
|
||||
try {
|
||||
fs.rmSync(realDir, { recursive: true, force: true });
|
||||
} catch {}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user