@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 CHANGED
@@ -280,7 +280,10 @@ var GitHubClient = class {
280
280
  });
281
281
  return true;
282
282
  } catch (err) {
283
- if (err instanceof Error && err.message.includes("404")) {
283
+ if (err && typeof err === "object" && "status" in err && err.status === 404) {
284
+ return false;
285
+ }
286
+ if (err instanceof Error && (err.message.includes("404") || err.message.includes("Not Found"))) {
284
287
  return false;
285
288
  }
286
289
  throw err;
@@ -672,9 +675,14 @@ async function detectTestFile(filePath, ref, githubClient, testDirectory) {
672
675
  ...testPatterns.map((pattern) => `__tests__/${baseName}${pattern}`)
673
676
  ];
674
677
  for (const testPath of locations) {
675
- const exists = await githubClient.fileExists(ref, testPath);
676
- if (exists) {
677
- return testPath;
678
+ try {
679
+ const exists = await githubClient.fileExists(ref, testPath);
680
+ if (exists) {
681
+ return testPath;
682
+ }
683
+ } catch (err) {
684
+ debug(`Error checking test file ${testPath}: ${err instanceof Error ? err.message : String(err)}`);
685
+ continue;
678
686
  }
679
687
  }
680
688
  return void 0;
@@ -713,28 +721,18 @@ async function analyzeFile(filePath, content, changedRanges, ref, githubClient,
713
721
  }
714
722
 
715
723
  // src/utils/test-target-extractor.ts
724
+ import { minimatch } from "minimatch";
716
725
  async function extractTestTargets(files, githubClient, prHeadRef, config) {
717
726
  info(`Analyzing ${files.length} file(s) for test targets`);
718
727
  const diffs = parsePullRequestFiles(files);
719
- const globToRegex = (pattern) => {
720
- let regexStr = pattern.replace(/\./g, "\\.");
721
- regexStr = regexStr.replace(/\*\*\//g, "__DOUBLE_STAR_SLASH__");
722
- regexStr = regexStr.replace(/\*\*/g, "__DOUBLE_STAR__");
723
- regexStr = regexStr.replace(/\*/g, "[^/]*");
724
- regexStr = regexStr.replace(/__DOUBLE_STAR_SLASH__/g, "(.*/)?");
725
- regexStr = regexStr.replace(/__DOUBLE_STAR__/g, ".*");
726
- return new RegExp(`^${regexStr}$`);
727
- };
728
728
  const filteredDiffs = diffs.filter((diff) => {
729
729
  const matchesInclude = config.includePatterns.some((pattern) => {
730
- const regex = globToRegex(pattern);
731
- return regex.test(diff.filename);
730
+ return minimatch(diff.filename, pattern);
732
731
  });
733
732
  if (!matchesInclude)
734
733
  return false;
735
734
  const matchesExclude = config.excludePatterns.some((pattern) => {
736
- const regex = globToRegex(pattern);
737
- return regex.test(diff.filename);
735
+ return minimatch(diff.filename, pattern);
738
736
  });
739
737
  return !matchesExclude;
740
738
  });