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

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);