Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/loopover-engine/src/review/diff-file-priority.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { isTestPath } from "../signals/test-evidence.js";

export function diffFilePriority(path: string): number {
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;
if (/(^|\/)(dist|build|out|coverage|vendor|node_modules)\//i.test(path)) return 4;
// Must stay in sync with signals/path-matchers.ts's isVendoredFileFrom -- the two already had this
// obligation implicitly (bower_components/jspm_packages were added there in #2777 with no corresponding
// update here, #7526) and now match the same directory-name set exactly.
if (/(^|\/)(dist|build|out|coverage|vendor|vendored|third_party|third-party|node_modules|bower_components|jspm_packages)\//i.test(path)) return 4;
if (/\.(md|mdx|markdown|rst|adoc|asciidoc|txt)$/i.test(path)) return 2;
if (isTestPath(path)) return 1;
return 0;
Expand Down
20 changes: 20 additions & 0 deletions packages/loopover-engine/test/diff-file-priority.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,23 @@ test("predictedGateEngineInternals.sharesMeaningfulFile: a shared Cartfile.resol
);
assert.equal(predictedGateEngineInternals.sharesMeaningfulFile(["src/app.ts"], ["src/app.ts"]), true);
});

test("diffFilePriority: ranks every vendored-directory name path-matchers.ts's isVendoredFileFrom recognizes (#7526)", () => {
assert.equal(diffFilePriority("vendor/x.js"), 4);
assert.equal(diffFilePriority("vendored/x.js"), 4);
assert.equal(diffFilePriority("third_party/x.js"), 4);
assert.equal(diffFilePriority("third-party/x.js"), 4);
assert.equal(diffFilePriority("bower_components/x.js"), 4);
assert.equal(diffFilePriority("jspm_packages/x.js"), 4);
});

test("predictedGateEngineInternals.sharesMeaningfulFile: a file shared only under a vendored directory is not meaningful collision evidence (#7526)", () => {
assert.equal(
predictedGateEngineInternals.sharesMeaningfulFile(["third_party/lib.js"], ["third_party/lib.js"]),
false,
);
assert.equal(
predictedGateEngineInternals.sharesMeaningfulFile(["bower_components/lib.js"], ["bower_components/lib.js"]),
false,
);
});