Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart query server when external config changes #2289

Merged
merged 3 commits into from
Apr 12, 2023

Conversation

aeisenberg
Copy link
Contributor

@aeisenberg aeisenberg commented Apr 6, 2023

This avoids manually restarting the query server when this file changes.

Fixes #1141

Replace this with a description of the changes your pull request makes.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

This avoids manually restarting the query server when this file changes.
@aeisenberg aeisenberg requested a review from a team as a code owner April 6, 2023 21:09
@aeisenberg aeisenberg assigned aeisenberg and unassigned aeisenberg Apr 6, 2023
@@ -3,6 +3,7 @@
## [UNRELEASED]

- 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. [#22892289)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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. [#22892289)
- 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)

* 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) {
if (process.env.HOME) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not want to have this work on Windows? It seems like we can call os.homedir() to get the home directory in a platform independent way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah...right. I forgot about that. I will fix.

*/
function watchExternalConfigFile(app: ExtensionApp, ctx: ExtensionContext) {
if (process.env.HOME) {
const configPath = join(process.env.HOME, ".config/codeql", "config");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to be consistent in how we join here:

Suggested change
const configPath = join(process.env.HOME, ".config/codeql", "config");
const configPath = join(process.env.HOME, ".config", "codeql", "config");

@aeisenberg aeisenberg requested a review from koesie10 April 11, 2023 16:45
Comment on lines 1022 to 1023
if (homedir()) {
const configPath = join(homedir(), ".config", "codeql", "config");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Optional) I think it would be a little bit more safe and faster to store the homedir() result in a variable to avoid duplicate calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Done.

@aeisenberg aeisenberg force-pushed the aeisenberg/watch-external-config branch from d5952d3 to 6de58ec Compare April 12, 2023 15:15
@aeisenberg aeisenberg enabled auto-merge April 12, 2023 15:15
@aeisenberg aeisenberg merged commit b3ff1ed into main Apr 12, 2023
@aeisenberg aeisenberg deleted the aeisenberg/watch-external-config branch April 12, 2023 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change to ~/.config/codeql/config not reflected in workspace until restart
2 participants