@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/index.cjs CHANGED
@@ -441,7 +441,10 @@ var GitHubClient = class {
441
441
  });
442
442
  return true;
443
443
  } catch (err) {
444
- if (err instanceof Error && err.message.includes("404")) {
444
+ if (err && typeof err === "object" && "status" in err && err.status === 404) {
445
+ return false;
446
+ }
447
+ if (err instanceof Error && (err.message.includes("404") || err.message.includes("Not Found"))) {
445
448
  return false;
446
449
  }
447
450
  throw err;
@@ -728,9 +731,14 @@ async function detectTestFile(filePath, ref, githubClient, testDirectory) {
728
731
  ...testPatterns.map((pattern) => `__tests__/${baseName}${pattern}`)
729
732
  ];
730
733
  for (const testPath of locations) {
731
- const exists = await githubClient.fileExists(ref, testPath);
732
- if (exists) {
733
- return testPath;
734
+ try {
735
+ const exists = await githubClient.fileExists(ref, testPath);
736
+ if (exists) {
737
+ return testPath;
738
+ }
739
+ } catch (err) {
740
+ debug(`Error checking test file ${testPath}: ${err instanceof Error ? err.message : String(err)}`);
741
+ continue;
734
742
  }
735
743
  }
736
744
  return void 0;
@@ -769,28 +777,18 @@ async function analyzeFile(filePath, content, changedRanges, ref, githubClient,
769
777
  }
770
778
 
771
779
  // src/utils/test-target-extractor.ts
780
+ var import_minimatch = require("minimatch");
772
781
  async function extractTestTargets(files, githubClient, prHeadRef, config) {
773
782
  info(`Analyzing ${files.length} file(s) for test targets`);
774
783
  const diffs = parsePullRequestFiles(files);
775
- const globToRegex = (pattern) => {
776
- let regexStr = pattern.replace(/\./g, "\\.");
777
- regexStr = regexStr.replace(/\*\*\//g, "__DOUBLE_STAR_SLASH__");
778
- regexStr = regexStr.replace(/\*\*/g, "__DOUBLE_STAR__");
779
- regexStr = regexStr.replace(/\*/g, "[^/]*");
780
- regexStr = regexStr.replace(/__DOUBLE_STAR_SLASH__/g, "(.*/)?");
781
- regexStr = regexStr.replace(/__DOUBLE_STAR__/g, ".*");
782
- return new RegExp(`^${regexStr}$`);
783
- };
784
784
  const filteredDiffs = diffs.filter((diff) => {
785
785
  const matchesInclude = config.includePatterns.some((pattern) => {
786
- const regex = globToRegex(pattern);
787
- return regex.test(diff.filename);
786
+ return (0, import_minimatch.minimatch)(diff.filename, pattern);
788
787
  });
789
788
  if (!matchesInclude)
790
789
  return false;
791
790
  const matchesExclude = config.excludePatterns.some((pattern) => {
792
- const regex = globToRegex(pattern);
793
- return regex.test(diff.filename);
791
+ return (0, import_minimatch.minimatch)(diff.filename, pattern);
794
792
  });
795
793
  return !matchesExclude;
796
794
  });