mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
fix: improve error handling and logging for diff range path resolution
This commit is contained in:
16
lib/upload-lib.js
generated
16
lib/upload-lib.js
generated
@@ -107530,10 +107530,19 @@ function computeChangedFiles(baseFileOids, overlayFileOids) {
|
||||
}
|
||||
async function getDiffRangeFilePaths(sourceRoot, logger) {
|
||||
const jsonFilePath = getDiffRangesJsonFilePath();
|
||||
if (!fs3.existsSync(jsonFilePath)) {
|
||||
logger.debug(
|
||||
`No diff ranges JSON file found at ${jsonFilePath}; skipping.`
|
||||
);
|
||||
return [];
|
||||
}
|
||||
let contents;
|
||||
try {
|
||||
contents = await fs3.promises.readFile(jsonFilePath, "utf8");
|
||||
} catch {
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
`Failed to read diff ranges JSON file at ${jsonFilePath}: ${e}`
|
||||
);
|
||||
return [];
|
||||
}
|
||||
let diffRanges;
|
||||
@@ -107550,6 +107559,11 @@ async function getDiffRangeFilePaths(sourceRoot, logger) {
|
||||
);
|
||||
const repoRoot = await getGitRoot(sourceRoot);
|
||||
if (repoRoot === void 0) {
|
||||
if (getOptionalInput("source-root")) {
|
||||
throw new Error(
|
||||
"Cannot determine git root to convert diff range paths relative to source-root. Failing to avoid omitting files from the analysis."
|
||||
);
|
||||
}
|
||||
logger.warning(
|
||||
"Cannot determine git root; returning diff range paths as-is."
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user