Merge pull request #2289 from github/aeisenberg/watch-external-config
Restart query server when external config changes
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
- Fix bug where users could end up with the managed CodeQL CLI getting uninstalled during upgrades and not reinstalled. [#2294](https://github.com/github/vscode-codeql/pull/2294)
|
||||
- Fix bug that was causing code flows to not get updated when switching between results. [#2288](https://github.com/github/vscode-codeql/pull/2288)
|
||||
- Restart the CodeQL language server whenever the _CodeQL: Restart Query Server_ command is invoked. This avoids bugs where the CLI version changes to support new language features, but the language server is not updated. [#2238](https://github.com/github/vscode-codeql/pull/2238)
|
||||
- Avoid requiring a manual restart of the query server when the [external CLI config file](https://docs.github.com/en/code-security/codeql-cli/using-the-codeql-cli/specifying-command-options-in-a-codeql-configuration-file#using-a-codeql-configuration-file) changes. [#2289](https://github.com/github/vscode-codeql/pull/2289)
|
||||
|
||||
## 1.8.1 - 23 March 2023
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ export type BaseCommands = {
|
||||
"codeQL.restartQueryServer": () => Promise<void>;
|
||||
"codeQL.restartQueryServerOnConfigChange": () => Promise<void>;
|
||||
"codeQL.restartLegacyQueryServerOnConfigChange": () => Promise<void>;
|
||||
"codeQL.restartQueryServerOnExternalConfigChange": () => Promise<void>;
|
||||
};
|
||||
|
||||
// Commands used when working with queries in the editor
|
||||
|
||||
@@ -13,12 +13,13 @@ import {
|
||||
workspace,
|
||||
} from "vscode";
|
||||
import { LanguageClient } from "vscode-languageclient/node";
|
||||
import { arch, platform } from "os";
|
||||
import { arch, platform, homedir } from "os";
|
||||
import { ensureDir } from "fs-extra";
|
||||
import { join } from "path";
|
||||
import { dirSync } from "tmp-promise";
|
||||
import { testExplorerExtensionId, TestHub } from "vscode-test-adapter-api";
|
||||
import { lt, parse } from "semver";
|
||||
import { watch } from "chokidar";
|
||||
|
||||
import { AstViewer } from "./astViewer";
|
||||
import {
|
||||
@@ -194,6 +195,7 @@ function getCommands(
|
||||
"codeQL.restartQueryServer": restartQueryServer,
|
||||
"codeQL.restartQueryServerOnConfigChange": restartQueryServer,
|
||||
"codeQL.restartLegacyQueryServerOnConfigChange": restartQueryServer,
|
||||
"codeQL.restartQueryServerOnExternalConfigChange": restartQueryServer,
|
||||
"codeQL.copyVersion": async () => {
|
||||
const text = `CodeQL extension version: ${
|
||||
extension?.packageJSON.version
|
||||
@@ -672,6 +674,7 @@ async function activateWithInstalledDistribution(
|
||||
extLogger,
|
||||
);
|
||||
ctx.subscriptions.push(cliServer);
|
||||
watchExternalConfigFile(app, ctx);
|
||||
|
||||
const statusBar = new CodeQlStatusBarHandler(
|
||||
cliServer,
|
||||
@@ -1011,6 +1014,34 @@ async function activateWithInstalledDistribution(
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle changes to the external config file. This is used to restart the query server
|
||||
* when the user changes options.
|
||||
* See https://docs.github.com/en/code-security/codeql-cli/using-the-codeql-cli/specifying-command-options-in-a-codeql-configuration-file#using-a-codeql-configuration-file
|
||||
*/
|
||||
function watchExternalConfigFile(app: ExtensionApp, ctx: ExtensionContext) {
|
||||
const home = homedir();
|
||||
if (home) {
|
||||
const configPath = join(home, ".config", "codeql", "config");
|
||||
const configWatcher = watch(configPath, {
|
||||
// These options avoid firing the event twice.
|
||||
persistent: true,
|
||||
ignoreInitial: true,
|
||||
awaitWriteFinish: true,
|
||||
});
|
||||
configWatcher.on("all", async () => {
|
||||
await app.commands.execute(
|
||||
"codeQL.restartQueryServerOnExternalConfigChange",
|
||||
);
|
||||
});
|
||||
ctx.subscriptions.push({
|
||||
dispose: () => {
|
||||
void configWatcher.close();
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function showResultsForComparison(
|
||||
compareView: CompareView,
|
||||
from: CompletedLocalQueryInfo,
|
||||
|
||||
Reference in New Issue
Block a user