@kakarot-ci/core 0.6.1 → 0.6.3
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/cli/index.js +15 -17
- package/dist/cli/index.js.map +2 -2
- package/dist/index.cjs +15 -17
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +15 -17
- package/dist/index.js.map +2 -2
- package/dist/src/github/client.d.ts.map +1 -1
- package/dist/src/utils/ast-analyzer.d.ts.map +1 -1
- package/dist/src/utils/test-target-extractor.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -375,7 +375,10 @@ var GitHubClient = class {
|
|
|
375
375
|
});
|
|
376
376
|
return true;
|
|
377
377
|
} catch (err) {
|
|
378
|
-
if (err
|
|
378
|
+
if (err && typeof err === "object" && "status" in err && err.status === 404) {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
if (err instanceof Error && (err.message.includes("404") || err.message.includes("Not Found"))) {
|
|
379
382
|
return false;
|
|
380
383
|
}
|
|
381
384
|
throw err;
|
|
@@ -662,9 +665,14 @@ async function detectTestFile(filePath, ref, githubClient, testDirectory) {
|
|
|
662
665
|
...testPatterns.map((pattern) => `__tests__/${baseName}${pattern}`)
|
|
663
666
|
];
|
|
664
667
|
for (const testPath of locations) {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
+
try {
|
|
669
|
+
const exists = await githubClient.fileExists(ref, testPath);
|
|
670
|
+
if (exists) {
|
|
671
|
+
return testPath;
|
|
672
|
+
}
|
|
673
|
+
} catch (err) {
|
|
674
|
+
debug(`Error checking test file ${testPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
675
|
+
continue;
|
|
668
676
|
}
|
|
669
677
|
}
|
|
670
678
|
return void 0;
|
|
@@ -703,28 +711,18 @@ async function analyzeFile(filePath, content, changedRanges, ref, githubClient,
|
|
|
703
711
|
}
|
|
704
712
|
|
|
705
713
|
// src/utils/test-target-extractor.ts
|
|
714
|
+
import { minimatch } from "minimatch";
|
|
706
715
|
async function extractTestTargets(files, githubClient, prHeadRef, config) {
|
|
707
716
|
info(`Analyzing ${files.length} file(s) for test targets`);
|
|
708
717
|
const diffs = parsePullRequestFiles(files);
|
|
709
|
-
const globToRegex = (pattern) => {
|
|
710
|
-
let regexStr = pattern.replace(/\./g, "\\.");
|
|
711
|
-
regexStr = regexStr.replace(/\*\*\//g, "__DOUBLE_STAR_SLASH__");
|
|
712
|
-
regexStr = regexStr.replace(/\*\*/g, "__DOUBLE_STAR__");
|
|
713
|
-
regexStr = regexStr.replace(/\*/g, "[^/]*");
|
|
714
|
-
regexStr = regexStr.replace(/__DOUBLE_STAR_SLASH__/g, "(.*/)?");
|
|
715
|
-
regexStr = regexStr.replace(/__DOUBLE_STAR__/g, ".*");
|
|
716
|
-
return new RegExp(`^${regexStr}$`);
|
|
717
|
-
};
|
|
718
718
|
const filteredDiffs = diffs.filter((diff) => {
|
|
719
719
|
const matchesInclude = config.includePatterns.some((pattern) => {
|
|
720
|
-
|
|
721
|
-
return regex.test(diff.filename);
|
|
720
|
+
return minimatch(diff.filename, pattern);
|
|
722
721
|
});
|
|
723
722
|
if (!matchesInclude)
|
|
724
723
|
return false;
|
|
725
724
|
const matchesExclude = config.excludePatterns.some((pattern) => {
|
|
726
|
-
|
|
727
|
-
return regex.test(diff.filename);
|
|
725
|
+
return minimatch(diff.filename, pattern);
|
|
728
726
|
});
|
|
729
727
|
return !matchesExclude;
|
|
730
728
|
});
|