@pratik7368patil/anchor-core 0.1.31 → 0.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +29 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2695,19 +2695,36 @@ function insertPrCochangeTestLinks(db, repoId, filePaths) {
|
|
|
2695
2695
|
}
|
|
2696
2696
|
}
|
|
2697
2697
|
function insertTestAwareness(db, repoId, repo, testFiles, testLinks, options = {}) {
|
|
2698
|
+
const dedupedTestFilesByPath = /* @__PURE__ */ new Map();
|
|
2699
|
+
for (const file of testFiles) dedupedTestFilesByPath.set(file.path, file);
|
|
2700
|
+
const dedupedTestFiles = [...dedupedTestFilesByPath.values()];
|
|
2701
|
+
const dedupedTestLinksByKey = /* @__PURE__ */ new Map();
|
|
2702
|
+
for (const link of testLinks) {
|
|
2703
|
+
const key = `${link.sourcePath}\0${link.testPath}\0${link.reason}`;
|
|
2704
|
+
const existing = dedupedTestLinksByKey.get(key);
|
|
2705
|
+
if (!existing || link.strength > existing.strength) {
|
|
2706
|
+
dedupedTestLinksByKey.set(key, link);
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
const dedupedTestLinks = [...dedupedTestLinksByKey.values()];
|
|
2698
2710
|
const insertTestFile = db.prepare(
|
|
2699
2711
|
`INSERT INTO test_files
|
|
2700
2712
|
(repo_id, path, language, size_bytes, content_hash, updated_at)
|
|
2701
|
-
VALUES (?, ?, ?, ?, ?, ?)
|
|
2713
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
2714
|
+
ON CONFLICT(repo_id, path) DO UPDATE SET
|
|
2715
|
+
language = excluded.language,
|
|
2716
|
+
size_bytes = excluded.size_bytes,
|
|
2717
|
+
content_hash = excluded.content_hash,
|
|
2718
|
+
updated_at = excluded.updated_at`
|
|
2702
2719
|
);
|
|
2703
2720
|
options.onProgress?.({
|
|
2704
2721
|
stage: "writing_test_awareness",
|
|
2705
2722
|
repo,
|
|
2706
2723
|
current: 0,
|
|
2707
|
-
total:
|
|
2724
|
+
total: dedupedTestFiles.length,
|
|
2708
2725
|
kind: "test_files"
|
|
2709
2726
|
});
|
|
2710
|
-
for (const [index, file] of
|
|
2727
|
+
for (const [index, file] of dedupedTestFiles.entries()) {
|
|
2711
2728
|
insertTestFile.run(
|
|
2712
2729
|
repoId,
|
|
2713
2730
|
file.path,
|
|
@@ -2717,36 +2734,38 @@ function insertTestAwareness(db, repoId, repo, testFiles, testLinks, options = {
|
|
|
2717
2734
|
file.updatedAt
|
|
2718
2735
|
);
|
|
2719
2736
|
const current = index + 1;
|
|
2720
|
-
if (shouldEmitCodeWriteProgress(current,
|
|
2737
|
+
if (shouldEmitCodeWriteProgress(current, dedupedTestFiles.length)) {
|
|
2721
2738
|
options.onProgress?.({
|
|
2722
2739
|
stage: "writing_test_awareness",
|
|
2723
2740
|
repo,
|
|
2724
2741
|
current,
|
|
2725
|
-
total:
|
|
2742
|
+
total: dedupedTestFiles.length,
|
|
2726
2743
|
kind: "test_files"
|
|
2727
2744
|
});
|
|
2728
2745
|
}
|
|
2729
2746
|
}
|
|
2730
2747
|
const insertTestLink = db.prepare(
|
|
2731
2748
|
`INSERT INTO test_links (repo_id, source_path, test_path, reason, strength)
|
|
2732
|
-
VALUES (?, ?, ?, ?, ?)
|
|
2749
|
+
VALUES (?, ?, ?, ?, ?)
|
|
2750
|
+
ON CONFLICT(repo_id, source_path, test_path, reason) DO UPDATE SET
|
|
2751
|
+
strength = excluded.strength`
|
|
2733
2752
|
);
|
|
2734
2753
|
options.onProgress?.({
|
|
2735
2754
|
stage: "writing_test_awareness",
|
|
2736
2755
|
repo,
|
|
2737
2756
|
current: 0,
|
|
2738
|
-
total:
|
|
2757
|
+
total: dedupedTestLinks.length,
|
|
2739
2758
|
kind: "test_links"
|
|
2740
2759
|
});
|
|
2741
|
-
for (const [index, link] of
|
|
2760
|
+
for (const [index, link] of dedupedTestLinks.entries()) {
|
|
2742
2761
|
insertTestLink.run(repoId, link.sourcePath, link.testPath, link.reason, link.strength);
|
|
2743
2762
|
const current = index + 1;
|
|
2744
|
-
if (shouldEmitCodeWriteProgress(current,
|
|
2763
|
+
if (shouldEmitCodeWriteProgress(current, dedupedTestLinks.length)) {
|
|
2745
2764
|
options.onProgress?.({
|
|
2746
2765
|
stage: "writing_test_awareness",
|
|
2747
2766
|
repo,
|
|
2748
2767
|
current,
|
|
2749
|
-
total:
|
|
2768
|
+
total: dedupedTestLinks.length,
|
|
2750
2769
|
kind: "test_links"
|
|
2751
2770
|
});
|
|
2752
2771
|
}
|