Make the command conditional on a supported CLI version

This commit is contained in:
Nora Dimitrijević
2023-10-12 18:07:09 +02:00
parent 8b918bdb19
commit b097804ad7
2 changed files with 17 additions and 0 deletions

View File

@@ -1810,6 +1810,10 @@
{
"command": "codeQL.gotoQLContextEditor",
"when": "false"
},
{
"command": "codeQL.trimCache",
"when": "codeql.supportsTrimCache"
}
],
"editor/context": [

View File

@@ -1492,6 +1492,13 @@ export class CodeQLCliServer implements Disposable {
CliVersionConstraint.CLI_VERSION_WITH_QUICK_EVAL_COUNT,
) >= 0,
);
await this.app.commands.execute(
"setContext",
"codeql.supportsTrimCache",
newVersion.compare(
CliVersionConstraint.CLI_VERSION_WITH_TRIM_CACHE,
) >= 0,
);
} catch (e) {
this._versionChangedListeners.forEach((listener) =>
listener(undefined),
@@ -1755,6 +1762,12 @@ export class CliVersionConstraint {
"2.14.0",
);
/**
* CLI version where the query server supports the `evaluation/trimCache` method
* with `codeql database cleanup --mode=trim` semantics.
*/
public static CLI_VERSION_WITH_TRIM_CACHE = new SemVer("2.15.1");
constructor(private readonly cli: CodeQLCliServer) {
/**/
}