mirror of
https://github.com/github/codeql-action.git
synced 2026-04-29 18:30:14 +00:00
Move diff-range extension pack generation into testable function
This commit is contained in:
Generated
+24
-21
@@ -91324,6 +91324,29 @@ async function setupDiffInformedQueryRun(branches, logger) {
|
||||
}
|
||||
);
|
||||
}
|
||||
function diffRangeExtensionPackContents(ranges) {
|
||||
const header = `
|
||||
extensions:
|
||||
- addsTo:
|
||||
pack: codeql/util
|
||||
extensible: restrictAlertsTo
|
||||
checkPresence: false
|
||||
data:
|
||||
`;
|
||||
let data = ranges.map(
|
||||
(range) => (
|
||||
// Using yaml.dump() with `forceQuotes: true` ensures that all special
|
||||
// characters are escaped, and that the path is always rendered as a
|
||||
// quoted string on a single line.
|
||||
` - [${dump(range.path, { forceQuotes: true }).trim()}, ${range.startLine}, ${range.endLine}]
|
||||
`
|
||||
)
|
||||
).join("");
|
||||
if (!data) {
|
||||
data = ' - ["", 0, 0]\n';
|
||||
}
|
||||
return header + data;
|
||||
}
|
||||
function writeDiffRangeDataExtensionPack(logger, ranges) {
|
||||
if (ranges === void 0) {
|
||||
return void 0;
|
||||
@@ -91345,27 +91368,7 @@ dataExtensions:
|
||||
- pr-diff-range.yml
|
||||
`
|
||||
);
|
||||
const header = `
|
||||
extensions:
|
||||
- addsTo:
|
||||
pack: codeql/util
|
||||
extensible: restrictAlertsTo
|
||||
checkPresence: false
|
||||
data:
|
||||
`;
|
||||
let data = ranges.map(
|
||||
(range) => (
|
||||
// Using yaml.dump() with `forceQuotes: true` ensures that all special
|
||||
// characters are escaped, and that the path is always rendered as a
|
||||
// quoted string on a single line.
|
||||
` - [${dump(range.path, { forceQuotes: true }).trim()}, ${range.startLine}, ${range.endLine}]
|
||||
`
|
||||
)
|
||||
).join("");
|
||||
if (!data) {
|
||||
data = ' - ["", 0, 0]\n';
|
||||
}
|
||||
const extensionContents = header + data;
|
||||
const extensionContents = diffRangeExtensionPackContents(ranges);
|
||||
const extensionFilePath = path12.join(diffRangeDir, "pr-diff-range.yml");
|
||||
fs12.writeFileSync(extensionFilePath, extensionContents);
|
||||
logger.debug(
|
||||
|
||||
Reference in New Issue
Block a user