Skip to content

Commit 1a019ab

Browse files
fix(engine): diffFilePriority's vendored-directory pattern misses vendored/third_party/third-party/bower_components/jspm_packages (#7540)
* fix(engine): diffFilePriority's vendored-directory pattern misses vendored/third_party/third-party/bower_components/jspm_packages diffFilePriority's priority-4 ("least-useful-to-review, never real collision evidence") directory alternation only matched vendor (singular), while the sibling isVendoredFileFrom matcher in path-matchers.ts already recognized vendored, third_party, third-party, bower_components, and jspm_packages too. A file shared between two unrelated PRs under one of those paths was ranked priority 0 (ordinary source) instead of 4, inflating sharesMeaningfulFile's collision/duplicate-cluster signal on exactly the kind of vendored-artifact path both call sites' own doc comments say should be excluded. Closes #7526 * chore: retrigger CI (transient Codecov GPG signature verification failure) The previous CI run's Codecov upload step failed on both shards with "gpg: no valid OpenPGP data found" / "Can't check signature: No public key" -- a transient Codecov CLI key-server issue during a narrow ~10s window, unrelated to this PR's code (a separate PR's run minutes earlier uploaded successfully with the identical action). Empty commit to force a fresh CI run since re-running the existing workflow run requires admin rights on JSONbored/loopover this account doesn't have.
1 parent 3a4ffa6 commit 1a019ab

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

packages/loopover-engine/src/review/diff-file-priority.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { isTestPath } from "../signals/test-evidence.js";
22

33
export function diffFilePriority(path: string): number {
44
if (/(^|\/)(package-lock\.json|npm-shrinkwrap\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lock|bun\.lockb|cargo\.lock|poetry\.lock|pipfile\.lock|composer\.lock|gemfile\.lock|go\.sum|go\.work\.sum|uv\.lock|packages\.lock\.json|flake\.lock|deno\.lock|pubspec\.lock|podfile\.lock|mix\.lock|package\.resolved|gradle\.lockfile|pdm\.lock|conan\.lock|pixi\.lock|cartfile\.resolved|gopkg\.lock|shard\.lock|rebar\.lock|renv\.lock|chart\.lock)$|\.(min\.(js|css)|map|snap)$/i.test(path)) return 4;
5-
if (/(^|\/)(dist|build|out|coverage|vendor|node_modules)\//i.test(path)) return 4;
5+
// Must stay in sync with signals/path-matchers.ts's isVendoredFileFrom -- the two already had this
6+
// obligation implicitly (bower_components/jspm_packages were added there in #2777 with no corresponding
7+
// update here, #7526) and now match the same directory-name set exactly.
8+
if (/(^|\/)(dist|build|out|coverage|vendor|vendored|third_party|third-party|node_modules|bower_components|jspm_packages)\//i.test(path)) return 4;
69
if (/\.(md|mdx|markdown|rst|adoc|asciidoc|txt)$/i.test(path)) return 2;
710
if (isTestPath(path)) return 1;
811
return 0;

packages/loopover-engine/test/diff-file-priority.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,23 @@ test("predictedGateEngineInternals.sharesMeaningfulFile: a shared Cartfile.resol
3030
);
3131
assert.equal(predictedGateEngineInternals.sharesMeaningfulFile(["src/app.ts"], ["src/app.ts"]), true);
3232
});
33+
34+
test("diffFilePriority: ranks every vendored-directory name path-matchers.ts's isVendoredFileFrom recognizes (#7526)", () => {
35+
assert.equal(diffFilePriority("vendor/x.js"), 4);
36+
assert.equal(diffFilePriority("vendored/x.js"), 4);
37+
assert.equal(diffFilePriority("third_party/x.js"), 4);
38+
assert.equal(diffFilePriority("third-party/x.js"), 4);
39+
assert.equal(diffFilePriority("bower_components/x.js"), 4);
40+
assert.equal(diffFilePriority("jspm_packages/x.js"), 4);
41+
});
42+
43+
test("predictedGateEngineInternals.sharesMeaningfulFile: a file shared only under a vendored directory is not meaningful collision evidence (#7526)", () => {
44+
assert.equal(
45+
predictedGateEngineInternals.sharesMeaningfulFile(["third_party/lib.js"], ["third_party/lib.js"]),
46+
false,
47+
);
48+
assert.equal(
49+
predictedGateEngineInternals.sharesMeaningfulFile(["bower_components/lib.js"], ["bower_components/lib.js"]),
50+
false,
51+
);
52+
});

0 commit comments

Comments
 (0)