Guard usage of cache-cleanup option by version check

This commit is contained in:
Simon Friis Vindum 2024-09-02 08:32:47 +02:00
parent e4525acbcb
commit 9a16e925c6
3 changed files with 21 additions and 3 deletions

9
lib/codeql.js generated
View file

@ -105,6 +105,10 @@ exports.CODEQL_VERSION_SUBLANGUAGE_FILE_COVERAGE = "2.15.0";
* Versions 2.15.2+ of the CodeQL CLI support the `--sarif-include-query-help` option.
*/
const CODEQL_VERSION_INCLUDE_QUERY_HELP = "2.15.2";
/**
* Versions 2.17.1+ of the CodeQL CLI support the `--cache-cleanup` option.
*/
const CODEQL_VERSION_CACHE_CLEANUP = "2.17.1";
/**
* Set up CodeQL CLI access.
*
@ -566,11 +570,14 @@ async function getCodeQLForCmd(cmd, checkVersion) {
}
},
async databaseCleanup(databasePath, cleanupLevel) {
const cacheCleanupFlag = (await util.codeQlVersionAtLeast(this, CODEQL_VERSION_CACHE_CLEANUP))
? "--cache-cleanup"
: "--mode";
const codeqlArgs = [
"database",
"cleanup",
databasePath,
`--cache-cleanup=${cleanupLevel}`,
`${cacheCleanupFlag}=${cleanupLevel}`,
...getExtraOptionsFromEnv(["database", "cleanup"]),
];
await runTool(cmd, codeqlArgs);

File diff suppressed because one or more lines are too long

View file

@ -327,6 +327,11 @@ export const CODEQL_VERSION_SUBLANGUAGE_FILE_COVERAGE = "2.15.0";
*/
const CODEQL_VERSION_INCLUDE_QUERY_HELP = "2.15.2";
/**
* Versions 2.17.1+ of the CodeQL CLI support the `--cache-cleanup` option.
*/
const CODEQL_VERSION_CACHE_CLEANUP = "2.17.1";
/**
* Set up CodeQL CLI access.
*
@ -966,11 +971,17 @@ export async function getCodeQLForCmd(
databasePath: string,
cleanupLevel: string,
): Promise<void> {
const cacheCleanupFlag = (await util.codeQlVersionAtLeast(
this,
CODEQL_VERSION_CACHE_CLEANUP,
))
? "--cache-cleanup"
: "--mode";
const codeqlArgs = [
"database",
"cleanup",
databasePath,
`--cache-cleanup=${cleanupLevel}`,
`${cacheCleanupFlag}=${cleanupLevel}`,
...getExtraOptionsFromEnv(["database", "cleanup"]),
];
await runTool(cmd, codeqlArgs);