mirror of
https://github.com/github/codeql-action.git
synced 2026-05-08 06:40:19 +00:00
Include diff-edidted files in overlay changes.
This commit is contained in:
Generated
+708
-639
File diff suppressed because it is too large
Load Diff
Generated
+53
-6
@@ -27720,15 +27720,15 @@ var require_pattern = __commonJS({
|
||||
exports2.removeDuplicateSlashes = removeDuplicateSlashes;
|
||||
function partitionAbsoluteAndRelative(patterns) {
|
||||
const absolute = [];
|
||||
const relative2 = [];
|
||||
const relative3 = [];
|
||||
for (const pattern of patterns) {
|
||||
if (isAbsolute2(pattern)) {
|
||||
absolute.push(pattern);
|
||||
} else {
|
||||
relative2.push(pattern);
|
||||
relative3.push(pattern);
|
||||
}
|
||||
}
|
||||
return [absolute, relative2];
|
||||
return [absolute, relative3];
|
||||
}
|
||||
exports2.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
|
||||
function isAbsolute2(pattern) {
|
||||
@@ -80536,8 +80536,8 @@ var require_follow_redirects = __commonJS({
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
function resolveUrl(relative2, base) {
|
||||
return useNativeURL ? new URL2(relative2, base) : parseUrl(url2.resolve(base, relative2));
|
||||
function resolveUrl(relative3, base) {
|
||||
return useNativeURL ? new URL2(relative3, base) : parseUrl(url2.resolve(base, relative3));
|
||||
}
|
||||
function validateUrl(input) {
|
||||
if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
|
||||
@@ -90922,8 +90922,38 @@ async function writeOverlayChangesFile(config, sourceRoot, logger) {
|
||||
const baseFileOids = await readBaseDatabaseOidsFile(config, logger);
|
||||
const overlayFileOids = await getFileOidsUnderPath(sourceRoot);
|
||||
const changedFiles = computeChangedFiles(baseFileOids, overlayFileOids);
|
||||
const originalCount = changedFiles.length;
|
||||
let forcedAddedCount = 0;
|
||||
try {
|
||||
const forced = getForcedOverlayFilesFromDiff(logger);
|
||||
if (forced.size > 0) {
|
||||
const existing = new Set(changedFiles);
|
||||
for (const f of forced) {
|
||||
if (!existing.has(f)) {
|
||||
if (overlayFileOids[f] !== void 0 || fs6.existsSync(path7.join(sourceRoot, f))) {
|
||||
existing.add(f);
|
||||
changedFiles.push(f);
|
||||
forcedAddedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (forcedAddedCount > 0) {
|
||||
logger.debug(
|
||||
`Force-included ${forcedAddedCount} file(s) from diff ranges into overlay: ${changedFiles.slice(-forcedAddedCount).join(", ")}`
|
||||
);
|
||||
} else {
|
||||
logger.debug(
|
||||
"All diff range files were already present in natural overlay changes (or none applicable)."
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logger.debug(
|
||||
`Failed while attempting to force-include diff range files in overlay: ${e.message || e}`
|
||||
);
|
||||
}
|
||||
logger.info(
|
||||
`Found ${changedFiles.length} changed file(s) under ${sourceRoot}.`
|
||||
`Found ${originalCount} natural changed file(s); force-added ${forcedAddedCount}; total ${changedFiles.length} under ${sourceRoot}.`
|
||||
);
|
||||
const changedFilesJson = JSON.stringify({ changes: changedFiles });
|
||||
const overlayChangesFile = path7.join(
|
||||
@@ -90950,6 +90980,23 @@ function computeChangedFiles(baseFileOids, overlayFileOids) {
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
function getForcedOverlayFilesFromDiff(logger) {
|
||||
const forced = /* @__PURE__ */ new Set();
|
||||
const diffRanges = readDiffRangesJsonFile(logger);
|
||||
if (!diffRanges || diffRanges.length === 0) {
|
||||
return forced;
|
||||
}
|
||||
const checkoutPath = getRequiredInput("checkout_path");
|
||||
for (const r of diffRanges) {
|
||||
const absPath = r.path;
|
||||
if (!absPath) continue;
|
||||
let rel = path7.relative(checkoutPath, absPath);
|
||||
if (!rel || rel.startsWith("..")) continue;
|
||||
rel = rel.split(path7.sep).join("/");
|
||||
forced.add(rel);
|
||||
}
|
||||
return forced;
|
||||
}
|
||||
var CACHE_VERSION = 1;
|
||||
var CACHE_PREFIX = "codeql-overlay-base-database";
|
||||
var MAX_CACHE_OPERATION_MS = 6e5;
|
||||
|
||||
Generated
+278
-209
File diff suppressed because it is too large
Load Diff
Generated
+75
-28
@@ -27720,15 +27720,15 @@ var require_pattern = __commonJS({
|
||||
exports2.removeDuplicateSlashes = removeDuplicateSlashes;
|
||||
function partitionAbsoluteAndRelative(patterns) {
|
||||
const absolute = [];
|
||||
const relative2 = [];
|
||||
const relative3 = [];
|
||||
for (const pattern of patterns) {
|
||||
if (isAbsolute2(pattern)) {
|
||||
absolute.push(pattern);
|
||||
} else {
|
||||
relative2.push(pattern);
|
||||
relative3.push(pattern);
|
||||
}
|
||||
}
|
||||
return [absolute, relative2];
|
||||
return [absolute, relative3];
|
||||
}
|
||||
exports2.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
|
||||
function isAbsolute2(pattern) {
|
||||
@@ -80536,8 +80536,8 @@ var require_follow_redirects = __commonJS({
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
function resolveUrl(relative2, base) {
|
||||
return useNativeURL ? new URL2(relative2, base) : parseUrl(url2.resolve(base, relative2));
|
||||
function resolveUrl(relative3, base) {
|
||||
return useNativeURL ? new URL2(relative3, base) : parseUrl(url2.resolve(base, relative3));
|
||||
}
|
||||
function validateUrl(input) {
|
||||
if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
|
||||
@@ -84278,8 +84278,8 @@ var require_readdir_glob = __commonJS({
|
||||
useStat = true;
|
||||
}
|
||||
const filename = dir + "/" + name;
|
||||
const relative2 = filename.slice(1);
|
||||
const absolute = path19 + "/" + relative2;
|
||||
const relative3 = filename.slice(1);
|
||||
const absolute = path19 + "/" + relative3;
|
||||
let stats = null;
|
||||
if (useStat || followSymlinks) {
|
||||
stats = await stat(absolute, followSymlinks);
|
||||
@@ -84291,12 +84291,12 @@ var require_readdir_glob = __commonJS({
|
||||
stats = { isDirectory: () => false };
|
||||
}
|
||||
if (stats.isDirectory()) {
|
||||
if (!shouldSkip(relative2)) {
|
||||
yield { relative: relative2, absolute, stats };
|
||||
if (!shouldSkip(relative3)) {
|
||||
yield { relative: relative3, absolute, stats };
|
||||
yield* exploreWalkAsync(filename, path19, followSymlinks, useStat, shouldSkip, false);
|
||||
}
|
||||
} else {
|
||||
yield { relative: relative2, absolute, stats };
|
||||
yield { relative: relative3, absolute, stats };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84366,11 +84366,11 @@ var require_readdir_glob = __commonJS({
|
||||
}
|
||||
setTimeout(() => this._next(), 0);
|
||||
}
|
||||
_shouldSkipDirectory(relative2) {
|
||||
return this.skipMatchers.some((m) => m.match(relative2));
|
||||
_shouldSkipDirectory(relative3) {
|
||||
return this.skipMatchers.some((m) => m.match(relative3));
|
||||
}
|
||||
_fileMatches(relative2, isDirectory2) {
|
||||
const file = relative2 + (isDirectory2 ? "/" : "");
|
||||
_fileMatches(relative3, isDirectory2) {
|
||||
const file = relative3 + (isDirectory2 ? "/" : "");
|
||||
return (this.matchers.length === 0 || this.matchers.some((m) => m.match(file))) && !this.ignoreMatchers.some((m) => m.match(file)) && (!this.options.nodir || !isDirectory2);
|
||||
}
|
||||
_next() {
|
||||
@@ -84379,16 +84379,16 @@ var require_readdir_glob = __commonJS({
|
||||
if (!obj.done) {
|
||||
const isDirectory2 = obj.value.stats.isDirectory();
|
||||
if (this._fileMatches(obj.value.relative, isDirectory2)) {
|
||||
let relative2 = obj.value.relative;
|
||||
let relative3 = obj.value.relative;
|
||||
let absolute = obj.value.absolute;
|
||||
if (this.options.mark && isDirectory2) {
|
||||
relative2 += "/";
|
||||
relative3 += "/";
|
||||
absolute += "/";
|
||||
}
|
||||
if (this.options.stat) {
|
||||
this.emit("match", { relative: relative2, absolute, stat: obj.value.stats });
|
||||
this.emit("match", { relative: relative3, absolute, stat: obj.value.stats });
|
||||
} else {
|
||||
this.emit("match", { relative: relative2, absolute });
|
||||
this.emit("match", { relative: relative3, absolute });
|
||||
}
|
||||
}
|
||||
this._next(this.iterator);
|
||||
@@ -89873,8 +89873,8 @@ var require_primordials = __commonJS({
|
||||
ArrayPrototypeIndexOf(self2, el) {
|
||||
return self2.indexOf(el);
|
||||
},
|
||||
ArrayPrototypeJoin(self2, sep5) {
|
||||
return self2.join(sep5);
|
||||
ArrayPrototypeJoin(self2, sep6) {
|
||||
return self2.join(sep6);
|
||||
},
|
||||
ArrayPrototypeMap(self2, fn) {
|
||||
return self2.map(fn);
|
||||
@@ -101761,7 +101761,7 @@ var require_commonjs16 = __commonJS({
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
constructor(cwd = process.cwd(), pathImpl, sep5, { nocase, childrenCacheSize = 16 * 1024, fs: fs20 = defaultFS } = {}) {
|
||||
constructor(cwd = process.cwd(), pathImpl, sep6, { nocase, childrenCacheSize = 16 * 1024, fs: fs20 = defaultFS } = {}) {
|
||||
this.#fs = fsFromOption(fs20);
|
||||
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
||||
cwd = (0, node_url_1.fileURLToPath)(cwd);
|
||||
@@ -101772,7 +101772,7 @@ var require_commonjs16 = __commonJS({
|
||||
this.#resolveCache = new ResolveCache();
|
||||
this.#resolvePosixCache = new ResolveCache();
|
||||
this.#children = new ChildrenCache(childrenCacheSize);
|
||||
const split = cwdPath.substring(this.rootPath.length).split(sep5);
|
||||
const split = cwdPath.substring(this.rootPath.length).split(sep6);
|
||||
if (split.length === 1 && !split[0]) {
|
||||
split.pop();
|
||||
}
|
||||
@@ -102615,10 +102615,10 @@ var require_ignore2 = __commonJS({
|
||||
ignored(p) {
|
||||
const fullpath = p.fullpath();
|
||||
const fullpaths = `${fullpath}/`;
|
||||
const relative2 = p.relative() || ".";
|
||||
const relatives = `${relative2}/`;
|
||||
const relative3 = p.relative() || ".";
|
||||
const relatives = `${relative3}/`;
|
||||
for (const m of this.relative) {
|
||||
if (m.match(relative2) || m.match(relatives))
|
||||
if (m.match(relative3) || m.match(relatives))
|
||||
return true;
|
||||
}
|
||||
for (const m of this.absolute) {
|
||||
@@ -102629,9 +102629,9 @@ var require_ignore2 = __commonJS({
|
||||
}
|
||||
childrenIgnored(p) {
|
||||
const fullpath = p.fullpath() + "/";
|
||||
const relative2 = (p.relative() || ".") + "/";
|
||||
const relative3 = (p.relative() || ".") + "/";
|
||||
for (const m of this.relativeChildren) {
|
||||
if (m.match(relative2))
|
||||
if (m.match(relative3))
|
||||
return true;
|
||||
}
|
||||
for (const m of this.absoluteChildren) {
|
||||
@@ -129189,8 +129189,38 @@ async function writeOverlayChangesFile(config, sourceRoot, logger) {
|
||||
const baseFileOids = await readBaseDatabaseOidsFile(config, logger);
|
||||
const overlayFileOids = await getFileOidsUnderPath(sourceRoot);
|
||||
const changedFiles = computeChangedFiles(baseFileOids, overlayFileOids);
|
||||
const originalCount = changedFiles.length;
|
||||
let forcedAddedCount = 0;
|
||||
try {
|
||||
const forced = getForcedOverlayFilesFromDiff(logger);
|
||||
if (forced.size > 0) {
|
||||
const existing = new Set(changedFiles);
|
||||
for (const f of forced) {
|
||||
if (!existing.has(f)) {
|
||||
if (overlayFileOids[f] !== void 0 || fs6.existsSync(path7.join(sourceRoot, f))) {
|
||||
existing.add(f);
|
||||
changedFiles.push(f);
|
||||
forcedAddedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (forcedAddedCount > 0) {
|
||||
logger.debug(
|
||||
`Force-included ${forcedAddedCount} file(s) from diff ranges into overlay: ${changedFiles.slice(-forcedAddedCount).join(", ")}`
|
||||
);
|
||||
} else {
|
||||
logger.debug(
|
||||
"All diff range files were already present in natural overlay changes (or none applicable)."
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logger.debug(
|
||||
`Failed while attempting to force-include diff range files in overlay: ${e.message || e}`
|
||||
);
|
||||
}
|
||||
logger.info(
|
||||
`Found ${changedFiles.length} changed file(s) under ${sourceRoot}.`
|
||||
`Found ${originalCount} natural changed file(s); force-added ${forcedAddedCount}; total ${changedFiles.length} under ${sourceRoot}.`
|
||||
);
|
||||
const changedFilesJson = JSON.stringify({ changes: changedFiles });
|
||||
const overlayChangesFile = path7.join(
|
||||
@@ -129217,6 +129247,23 @@ function computeChangedFiles(baseFileOids, overlayFileOids) {
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
function getForcedOverlayFilesFromDiff(logger) {
|
||||
const forced = /* @__PURE__ */ new Set();
|
||||
const diffRanges = readDiffRangesJsonFile(logger);
|
||||
if (!diffRanges || diffRanges.length === 0) {
|
||||
return forced;
|
||||
}
|
||||
const checkoutPath = getRequiredInput("checkout_path");
|
||||
for (const r of diffRanges) {
|
||||
const absPath = r.path;
|
||||
if (!absPath) continue;
|
||||
let rel = path7.relative(checkoutPath, absPath);
|
||||
if (!rel || rel.startsWith("..")) continue;
|
||||
rel = rel.split(path7.sep).join("/");
|
||||
forced.add(rel);
|
||||
}
|
||||
return forced;
|
||||
}
|
||||
|
||||
// src/tools-features.ts
|
||||
var semver3 = __toESM(require_semver2());
|
||||
|
||||
Generated
+66
-6
@@ -29628,15 +29628,15 @@ var require_pattern = __commonJS({
|
||||
exports2.removeDuplicateSlashes = removeDuplicateSlashes;
|
||||
function partitionAbsoluteAndRelative(patterns) {
|
||||
const absolute = [];
|
||||
const relative2 = [];
|
||||
const relative3 = [];
|
||||
for (const pattern of patterns) {
|
||||
if (isAbsolute3(pattern)) {
|
||||
absolute.push(pattern);
|
||||
} else {
|
||||
relative2.push(pattern);
|
||||
relative3.push(pattern);
|
||||
}
|
||||
}
|
||||
return [absolute, relative2];
|
||||
return [absolute, relative3];
|
||||
}
|
||||
exports2.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
|
||||
function isAbsolute3(pattern) {
|
||||
@@ -81633,8 +81633,8 @@ var require_follow_redirects = __commonJS({
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
function resolveUrl(relative2, base) {
|
||||
return useNativeURL ? new URL2(relative2, base) : parseUrl(url.resolve(base, relative2));
|
||||
function resolveUrl(relative3, base) {
|
||||
return useNativeURL ? new URL2(relative3, base) : parseUrl(url.resolve(base, relative3));
|
||||
}
|
||||
function validateUrl(input) {
|
||||
if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
|
||||
@@ -86812,8 +86812,38 @@ async function writeOverlayChangesFile(config, sourceRoot, logger) {
|
||||
const baseFileOids = await readBaseDatabaseOidsFile(config, logger);
|
||||
const overlayFileOids = await getFileOidsUnderPath(sourceRoot);
|
||||
const changedFiles = computeChangedFiles(baseFileOids, overlayFileOids);
|
||||
const originalCount = changedFiles.length;
|
||||
let forcedAddedCount = 0;
|
||||
try {
|
||||
const forced = getForcedOverlayFilesFromDiff(logger);
|
||||
if (forced.size > 0) {
|
||||
const existing = new Set(changedFiles);
|
||||
for (const f of forced) {
|
||||
if (!existing.has(f)) {
|
||||
if (overlayFileOids[f] !== void 0 || fs6.existsSync(path8.join(sourceRoot, f))) {
|
||||
existing.add(f);
|
||||
changedFiles.push(f);
|
||||
forcedAddedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (forcedAddedCount > 0) {
|
||||
logger.debug(
|
||||
`Force-included ${forcedAddedCount} file(s) from diff ranges into overlay: ${changedFiles.slice(-forcedAddedCount).join(", ")}`
|
||||
);
|
||||
} else {
|
||||
logger.debug(
|
||||
"All diff range files were already present in natural overlay changes (or none applicable)."
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logger.debug(
|
||||
`Failed while attempting to force-include diff range files in overlay: ${e.message || e}`
|
||||
);
|
||||
}
|
||||
logger.info(
|
||||
`Found ${changedFiles.length} changed file(s) under ${sourceRoot}.`
|
||||
`Found ${originalCount} natural changed file(s); force-added ${forcedAddedCount}; total ${changedFiles.length} under ${sourceRoot}.`
|
||||
);
|
||||
const changedFilesJson = JSON.stringify({ changes: changedFiles });
|
||||
const overlayChangesFile = path8.join(
|
||||
@@ -86840,6 +86870,23 @@ function computeChangedFiles(baseFileOids, overlayFileOids) {
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
function getForcedOverlayFilesFromDiff(logger) {
|
||||
const forced = /* @__PURE__ */ new Set();
|
||||
const diffRanges = readDiffRangesJsonFile(logger);
|
||||
if (!diffRanges || diffRanges.length === 0) {
|
||||
return forced;
|
||||
}
|
||||
const checkoutPath = getRequiredInput("checkout_path");
|
||||
for (const r of diffRanges) {
|
||||
const absPath = r.path;
|
||||
if (!absPath) continue;
|
||||
let rel = path8.relative(checkoutPath, absPath);
|
||||
if (!rel || rel.startsWith("..")) continue;
|
||||
rel = rel.split(path8.sep).join("/");
|
||||
forced.add(rel);
|
||||
}
|
||||
return forced;
|
||||
}
|
||||
var CACHE_VERSION = 1;
|
||||
var CACHE_PREFIX = "codeql-overlay-base-database";
|
||||
var MAX_CACHE_OPERATION_MS = 6e5;
|
||||
@@ -87455,6 +87502,19 @@ function writeDiffRangesJsonFile(logger, ranges) {
|
||||
${jsonContents}`
|
||||
);
|
||||
}
|
||||
function readDiffRangesJsonFile(logger) {
|
||||
const jsonFilePath = getDiffRangesJsonFilePath();
|
||||
if (!fs8.existsSync(jsonFilePath)) {
|
||||
logger.debug(`Diff ranges JSON file does not exist at ${jsonFilePath}`);
|
||||
return void 0;
|
||||
}
|
||||
const jsonContents = fs8.readFileSync(jsonFilePath, "utf8");
|
||||
logger.debug(
|
||||
`Read pr-diff-range JSON file from ${jsonFilePath}:
|
||||
${jsonContents}`
|
||||
);
|
||||
return JSON.parse(jsonContents);
|
||||
}
|
||||
async function getPullRequestEditedDiffRanges(branches, logger) {
|
||||
const fileDiffs = await getFileDiffsWithBasehead(branches, logger);
|
||||
if (fileDiffs === void 0) {
|
||||
|
||||
Generated
+273
-204
File diff suppressed because it is too large
Load Diff
Generated
+53
-6
@@ -29017,15 +29017,15 @@ var require_pattern = __commonJS({
|
||||
exports2.removeDuplicateSlashes = removeDuplicateSlashes;
|
||||
function partitionAbsoluteAndRelative(patterns) {
|
||||
const absolute = [];
|
||||
const relative2 = [];
|
||||
const relative3 = [];
|
||||
for (const pattern of patterns) {
|
||||
if (isAbsolute2(pattern)) {
|
||||
absolute.push(pattern);
|
||||
} else {
|
||||
relative2.push(pattern);
|
||||
relative3.push(pattern);
|
||||
}
|
||||
}
|
||||
return [absolute, relative2];
|
||||
return [absolute, relative3];
|
||||
}
|
||||
exports2.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
|
||||
function isAbsolute2(pattern) {
|
||||
@@ -81833,8 +81833,8 @@ var require_follow_redirects = __commonJS({
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
function resolveUrl(relative2, base) {
|
||||
return useNativeURL ? new URL2(relative2, base) : parseUrl(url2.resolve(base, relative2));
|
||||
function resolveUrl(relative3, base) {
|
||||
return useNativeURL ? new URL2(relative3, base) : parseUrl(url2.resolve(base, relative3));
|
||||
}
|
||||
function validateUrl(input) {
|
||||
if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
|
||||
@@ -89293,8 +89293,38 @@ async function writeOverlayChangesFile(config, sourceRoot, logger) {
|
||||
const baseFileOids = await readBaseDatabaseOidsFile(config, logger);
|
||||
const overlayFileOids = await getFileOidsUnderPath(sourceRoot);
|
||||
const changedFiles = computeChangedFiles(baseFileOids, overlayFileOids);
|
||||
const originalCount = changedFiles.length;
|
||||
let forcedAddedCount = 0;
|
||||
try {
|
||||
const forced = getForcedOverlayFilesFromDiff(logger);
|
||||
if (forced.size > 0) {
|
||||
const existing = new Set(changedFiles);
|
||||
for (const f of forced) {
|
||||
if (!existing.has(f)) {
|
||||
if (overlayFileOids[f] !== void 0 || fs5.existsSync(path7.join(sourceRoot, f))) {
|
||||
existing.add(f);
|
||||
changedFiles.push(f);
|
||||
forcedAddedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (forcedAddedCount > 0) {
|
||||
logger.debug(
|
||||
`Force-included ${forcedAddedCount} file(s) from diff ranges into overlay: ${changedFiles.slice(-forcedAddedCount).join(", ")}`
|
||||
);
|
||||
} else {
|
||||
logger.debug(
|
||||
"All diff range files were already present in natural overlay changes (or none applicable)."
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logger.debug(
|
||||
`Failed while attempting to force-include diff range files in overlay: ${e.message || e}`
|
||||
);
|
||||
}
|
||||
logger.info(
|
||||
`Found ${changedFiles.length} changed file(s) under ${sourceRoot}.`
|
||||
`Found ${originalCount} natural changed file(s); force-added ${forcedAddedCount}; total ${changedFiles.length} under ${sourceRoot}.`
|
||||
);
|
||||
const changedFilesJson = JSON.stringify({ changes: changedFiles });
|
||||
const overlayChangesFile = path7.join(
|
||||
@@ -89321,6 +89351,23 @@ function computeChangedFiles(baseFileOids, overlayFileOids) {
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
function getForcedOverlayFilesFromDiff(logger) {
|
||||
const forced = /* @__PURE__ */ new Set();
|
||||
const diffRanges = readDiffRangesJsonFile(logger);
|
||||
if (!diffRanges || diffRanges.length === 0) {
|
||||
return forced;
|
||||
}
|
||||
const checkoutPath = getRequiredInput("checkout_path");
|
||||
for (const r of diffRanges) {
|
||||
const absPath = r.path;
|
||||
if (!absPath) continue;
|
||||
let rel = path7.relative(checkoutPath, absPath);
|
||||
if (!rel || rel.startsWith("..")) continue;
|
||||
rel = rel.split(path7.sep).join("/");
|
||||
forced.add(rel);
|
||||
}
|
||||
return forced;
|
||||
}
|
||||
|
||||
// src/tools-features.ts
|
||||
var semver3 = __toESM(require_semver2());
|
||||
|
||||
Generated
+86
-39
@@ -27720,15 +27720,15 @@ var require_pattern = __commonJS({
|
||||
exports2.removeDuplicateSlashes = removeDuplicateSlashes;
|
||||
function partitionAbsoluteAndRelative(patterns) {
|
||||
const absolute = [];
|
||||
const relative2 = [];
|
||||
const relative3 = [];
|
||||
for (const pattern of patterns) {
|
||||
if (isAbsolute2(pattern)) {
|
||||
absolute.push(pattern);
|
||||
} else {
|
||||
relative2.push(pattern);
|
||||
relative3.push(pattern);
|
||||
}
|
||||
}
|
||||
return [absolute, relative2];
|
||||
return [absolute, relative3];
|
||||
}
|
||||
exports2.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
|
||||
function isAbsolute2(pattern) {
|
||||
@@ -81833,8 +81833,8 @@ var require_follow_redirects = __commonJS({
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
function resolveUrl(relative2, base) {
|
||||
return useNativeURL ? new URL2(relative2, base) : parseUrl(url2.resolve(base, relative2));
|
||||
function resolveUrl(relative3, base) {
|
||||
return useNativeURL ? new URL2(relative3, base) : parseUrl(url2.resolve(base, relative3));
|
||||
}
|
||||
function validateUrl(input) {
|
||||
if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
|
||||
@@ -88949,8 +88949,8 @@ function wrapApiConfigurationError(e) {
|
||||
}
|
||||
|
||||
// src/feature-flags.ts
|
||||
var fs6 = __toESM(require("fs"));
|
||||
var path8 = __toESM(require("path"));
|
||||
var fs7 = __toESM(require("fs"));
|
||||
var path9 = __toESM(require("path"));
|
||||
var semver3 = __toESM(require_semver2());
|
||||
|
||||
// src/defaults.json
|
||||
@@ -88958,8 +88958,8 @@ var bundleVersion = "codeql-bundle-v2.23.2";
|
||||
var cliVersion = "2.23.2";
|
||||
|
||||
// src/overlay-database-utils.ts
|
||||
var fs5 = __toESM(require("fs"));
|
||||
var path7 = __toESM(require("path"));
|
||||
var fs6 = __toESM(require("fs"));
|
||||
var path8 = __toESM(require("path"));
|
||||
var actionsCache = __toESM(require_cache3());
|
||||
|
||||
// src/git-utils.ts
|
||||
@@ -89159,6 +89159,26 @@ async function isAnalyzingDefaultBranch() {
|
||||
return currentRef === defaultBranch;
|
||||
}
|
||||
|
||||
// src/diff-informed-analysis-utils.ts
|
||||
var fs5 = __toESM(require("fs"));
|
||||
var path7 = __toESM(require("path"));
|
||||
function getDiffRangesJsonFilePath() {
|
||||
return path7.join(getTemporaryDirectory(), "pr-diff-range.json");
|
||||
}
|
||||
function readDiffRangesJsonFile(logger) {
|
||||
const jsonFilePath = getDiffRangesJsonFilePath();
|
||||
if (!fs5.existsSync(jsonFilePath)) {
|
||||
logger.debug(`Diff ranges JSON file does not exist at ${jsonFilePath}`);
|
||||
return void 0;
|
||||
}
|
||||
const jsonContents = fs5.readFileSync(jsonFilePath, "utf8");
|
||||
logger.debug(
|
||||
`Read pr-diff-range JSON file from ${jsonFilePath}:
|
||||
${jsonContents}`
|
||||
);
|
||||
return JSON.parse(jsonContents);
|
||||
}
|
||||
|
||||
// src/logging.ts
|
||||
var core7 = __toESM(require_core());
|
||||
function getActionsLogger() {
|
||||
@@ -89184,12 +89204,12 @@ async function writeBaseDatabaseOidsFile(config, sourceRoot) {
|
||||
const gitFileOids = await getFileOidsUnderPath(sourceRoot);
|
||||
const gitFileOidsJson = JSON.stringify(gitFileOids);
|
||||
const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config);
|
||||
await fs5.promises.writeFile(baseDatabaseOidsFilePath, gitFileOidsJson);
|
||||
await fs6.promises.writeFile(baseDatabaseOidsFilePath, gitFileOidsJson);
|
||||
}
|
||||
async function readBaseDatabaseOidsFile(config, logger) {
|
||||
const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config);
|
||||
try {
|
||||
const contents = await fs5.promises.readFile(
|
||||
const contents = await fs6.promises.readFile(
|
||||
baseDatabaseOidsFilePath,
|
||||
"utf-8"
|
||||
);
|
||||
@@ -89202,24 +89222,54 @@ async function readBaseDatabaseOidsFile(config, logger) {
|
||||
}
|
||||
}
|
||||
function getBaseDatabaseOidsFilePath(config) {
|
||||
return path7.join(config.dbLocation, "base-database-oids.json");
|
||||
return path8.join(config.dbLocation, "base-database-oids.json");
|
||||
}
|
||||
async function writeOverlayChangesFile(config, sourceRoot, logger) {
|
||||
const baseFileOids = await readBaseDatabaseOidsFile(config, logger);
|
||||
const overlayFileOids = await getFileOidsUnderPath(sourceRoot);
|
||||
const changedFiles = computeChangedFiles(baseFileOids, overlayFileOids);
|
||||
const originalCount = changedFiles.length;
|
||||
let forcedAddedCount = 0;
|
||||
try {
|
||||
const forced = getForcedOverlayFilesFromDiff(logger);
|
||||
if (forced.size > 0) {
|
||||
const existing = new Set(changedFiles);
|
||||
for (const f of forced) {
|
||||
if (!existing.has(f)) {
|
||||
if (overlayFileOids[f] !== void 0 || fs6.existsSync(path8.join(sourceRoot, f))) {
|
||||
existing.add(f);
|
||||
changedFiles.push(f);
|
||||
forcedAddedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (forcedAddedCount > 0) {
|
||||
logger.debug(
|
||||
`Force-included ${forcedAddedCount} file(s) from diff ranges into overlay: ${changedFiles.slice(-forcedAddedCount).join(", ")}`
|
||||
);
|
||||
} else {
|
||||
logger.debug(
|
||||
"All diff range files were already present in natural overlay changes (or none applicable)."
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logger.debug(
|
||||
`Failed while attempting to force-include diff range files in overlay: ${e.message || e}`
|
||||
);
|
||||
}
|
||||
logger.info(
|
||||
`Found ${changedFiles.length} changed file(s) under ${sourceRoot}.`
|
||||
`Found ${originalCount} natural changed file(s); force-added ${forcedAddedCount}; total ${changedFiles.length} under ${sourceRoot}.`
|
||||
);
|
||||
const changedFilesJson = JSON.stringify({ changes: changedFiles });
|
||||
const overlayChangesFile = path7.join(
|
||||
const overlayChangesFile = path8.join(
|
||||
getTemporaryDirectory(),
|
||||
"overlay-changes.json"
|
||||
);
|
||||
logger.debug(
|
||||
`Writing overlay changed files to ${overlayChangesFile}: ${changedFilesJson}`
|
||||
);
|
||||
await fs5.promises.writeFile(overlayChangesFile, changedFilesJson);
|
||||
await fs6.promises.writeFile(overlayChangesFile, changedFilesJson);
|
||||
return overlayChangesFile;
|
||||
}
|
||||
function computeChangedFiles(baseFileOids, overlayFileOids) {
|
||||
@@ -89236,6 +89286,23 @@ function computeChangedFiles(baseFileOids, overlayFileOids) {
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
function getForcedOverlayFilesFromDiff(logger) {
|
||||
const forced = /* @__PURE__ */ new Set();
|
||||
const diffRanges = readDiffRangesJsonFile(logger);
|
||||
if (!diffRanges || diffRanges.length === 0) {
|
||||
return forced;
|
||||
}
|
||||
const checkoutPath = getRequiredInput("checkout_path");
|
||||
for (const r of diffRanges) {
|
||||
const absPath = r.path;
|
||||
if (!absPath) continue;
|
||||
let rel = path8.relative(checkoutPath, absPath);
|
||||
if (!rel || rel.startsWith("..")) continue;
|
||||
rel = rel.split(path8.sep).join("/");
|
||||
forced.add(rel);
|
||||
}
|
||||
return forced;
|
||||
}
|
||||
|
||||
// src/tools-features.ts
|
||||
var semver2 = __toESM(require_semver2());
|
||||
@@ -89428,7 +89495,7 @@ var Features = class {
|
||||
this.gitHubFeatureFlags = new GitHubFeatureFlags(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
path8.join(tempDir, FEATURE_FLAGS_FILE_NAME),
|
||||
path9.join(tempDir, FEATURE_FLAGS_FILE_NAME),
|
||||
logger
|
||||
);
|
||||
}
|
||||
@@ -89607,12 +89674,12 @@ var GitHubFeatureFlags = class {
|
||||
}
|
||||
async readLocalFlags() {
|
||||
try {
|
||||
if (fs6.existsSync(this.featureFlagsFile)) {
|
||||
if (fs7.existsSync(this.featureFlagsFile)) {
|
||||
this.logger.debug(
|
||||
`Loading feature flags from ${this.featureFlagsFile}`
|
||||
);
|
||||
return JSON.parse(
|
||||
fs6.readFileSync(this.featureFlagsFile, "utf8")
|
||||
fs7.readFileSync(this.featureFlagsFile, "utf8")
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -89625,7 +89692,7 @@ var GitHubFeatureFlags = class {
|
||||
async writeLocalFlags(flags) {
|
||||
try {
|
||||
this.logger.debug(`Writing feature flags to ${this.featureFlagsFile}`);
|
||||
fs6.writeFileSync(this.featureFlagsFile, JSON.stringify(flags));
|
||||
fs7.writeFileSync(this.featureFlagsFile, JSON.stringify(flags));
|
||||
} catch (e) {
|
||||
this.logger.warning(
|
||||
`Error writing cached feature flags file ${this.featureFlagsFile}: ${e}.`
|
||||
@@ -89706,26 +89773,6 @@ var PACK_IDENTIFIER_PATTERN = (function() {
|
||||
return new RegExp(`^${component}/${component}$`);
|
||||
})();
|
||||
|
||||
// src/diff-informed-analysis-utils.ts
|
||||
var fs7 = __toESM(require("fs"));
|
||||
var path9 = __toESM(require("path"));
|
||||
function getDiffRangesJsonFilePath() {
|
||||
return path9.join(getTemporaryDirectory(), "pr-diff-range.json");
|
||||
}
|
||||
function readDiffRangesJsonFile(logger) {
|
||||
const jsonFilePath = getDiffRangesJsonFilePath();
|
||||
if (!fs7.existsSync(jsonFilePath)) {
|
||||
logger.debug(`Diff ranges JSON file does not exist at ${jsonFilePath}`);
|
||||
return void 0;
|
||||
}
|
||||
const jsonContents = fs7.readFileSync(jsonFilePath, "utf8");
|
||||
logger.debug(
|
||||
`Read pr-diff-range JSON file from ${jsonFilePath}:
|
||||
${jsonContents}`
|
||||
);
|
||||
return JSON.parse(jsonContents);
|
||||
}
|
||||
|
||||
// src/trap-caching.ts
|
||||
var actionsCache2 = __toESM(require_cache3());
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import { getAutomationID } from "./api-client";
|
||||
import { type CodeQL } from "./codeql";
|
||||
import { type Config } from "./config-utils";
|
||||
import { getCommitOid, getFileOidsUnderPath } from "./git-utils";
|
||||
import { readDiffRangesJsonFile } from "./diff-informed-analysis-utils";
|
||||
import { Logger, withGroupAsync } from "./logging";
|
||||
import {
|
||||
isInTestMode,
|
||||
@@ -121,8 +122,43 @@ export async function writeOverlayChangesFile(
|
||||
const baseFileOids = await readBaseDatabaseOidsFile(config, logger);
|
||||
const overlayFileOids = await getFileOidsUnderPath(sourceRoot);
|
||||
const changedFiles = computeChangedFiles(baseFileOids, overlayFileOids);
|
||||
|
||||
// Augment changed files with any files that appear in the precomputed PR diff ranges.
|
||||
// This ensures overlay analysis always includes every file with at least one edited range.
|
||||
const originalCount = changedFiles.length;
|
||||
let extraAddedCount = 0;
|
||||
try {
|
||||
const diffChangedFiles = getFilesFromDiff(logger);
|
||||
if (diffChangedFiles.size > 0) {
|
||||
const existing = new Set(changedFiles);
|
||||
for (const f of diffChangedFiles) {
|
||||
if (!existing.has(f)) {
|
||||
// Only include if file still exists (added/modified) — skip deleted files that might appear in diff.
|
||||
if (overlayFileOids[f] !== undefined || fs.existsSync(path.join(sourceRoot, f))) {
|
||||
existing.add(f);
|
||||
changedFiles.push(f);
|
||||
extraAddedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (extraAddedCount > 0) {
|
||||
logger.debug(
|
||||
`Added ${extraAddedCount} file(s) from PR diff ranges into overlay: ${changedFiles.slice(-extraAddedCount).join(", ")}`,
|
||||
);
|
||||
} else {
|
||||
logger.debug(
|
||||
"All diff range files were already present in the diff from the base database.",
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logger.debug(
|
||||
`Failed while attempting to add diff range files in overlay: ${(e as any).message || e}`,
|
||||
);
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`Found ${changedFiles.length} changed file(s) under ${sourceRoot}.`,
|
||||
`Found ${originalCount} natural changed file(s); added from diff ${extraAddedCount}; total ${changedFiles.length} under ${sourceRoot}.`,
|
||||
);
|
||||
|
||||
const changedFilesJson = JSON.stringify({ changes: changedFiles });
|
||||
@@ -155,6 +191,22 @@ function computeChangedFiles(
|
||||
return changes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Derive the set of repository-relative file paths that have at least one edited range
|
||||
* in the precomputed diff ranges JSON. Returns an empty set if no JSON exists.
|
||||
*/
|
||||
function getFilesFromDiff(logger: Logger): Set<string> {
|
||||
const forced = new Set<string>();
|
||||
const diffRanges = readDiffRangesJsonFile(logger);
|
||||
if (!diffRanges || diffRanges.length === 0) {
|
||||
return forced;
|
||||
}
|
||||
for (const r of diffRanges) {
|
||||
forced.add(r.path);
|
||||
}
|
||||
return forced;
|
||||
}
|
||||
|
||||
// Constants for database caching
|
||||
const CACHE_VERSION = 1;
|
||||
const CACHE_PREFIX = "codeql-overlay-base-database";
|
||||
|
||||
Reference in New Issue
Block a user