-
Notifications
You must be signed in to change notification settings - Fork 226
Handle codeql-pack.yml files everywhere
#2054
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,9 +12,11 @@ import { LSPErrorCodes, ResponseError } from "vscode-languageclient"; | |
| import { CodeQLCliServer } from "./cli"; | ||
| import { DatabaseUI } from "./databases-ui"; | ||
| import { | ||
| FALLBACK_QLPACK_FILENAME, | ||
| getInitialQueryContents, | ||
| getPrimaryDbscheme, | ||
| getQlPackForDbscheme, | ||
| getQlPackPath, | ||
| showBinaryChoiceDialog, | ||
| } from "./helpers"; | ||
| import { ProgressCallback, UserCancellationException } from "./commandRunner"; | ||
|
|
@@ -112,7 +114,7 @@ export async function displayQuickQuery( | |
| const dbscheme = await getPrimaryDbscheme(datasetFolder); | ||
| const qlpack = (await getQlPackForDbscheme(cliServer, dbscheme)) | ||
| .dbschemePack; | ||
| const qlPackFile = join(queriesDir, "qlpack.yml"); | ||
| const qlPackFile = await getQlPackPath(queriesDir); | ||
| const qlFile = join(queriesDir, QUICK_QUERY_QUERY_NAME); | ||
| const shouldRewrite = await checkShouldRewrite(qlPackFile, qlpack); | ||
|
|
||
|
|
@@ -126,7 +128,7 @@ export async function displayQuickQuery( | |
| }, | ||
| }; | ||
| await writeFile( | ||
| qlPackFile, | ||
| qlPackFile ?? join(queriesDir, FALLBACK_QLPACK_FILENAME), | ||
| QLPACK_FILE_HEADER + dump(quickQueryQlpackYaml), | ||
| "utf8", | ||
| ); | ||
|
|
@@ -158,7 +160,13 @@ export async function displayQuickQuery( | |
| } | ||
| } | ||
|
|
||
| async function checkShouldRewrite(qlPackFile: string, newDependency: string) { | ||
| async function checkShouldRewrite( | ||
| qlPackFile: string | undefined, | ||
| newDependency: string, | ||
| ) { | ||
| if (!qlPackFile) { | ||
| return true; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see we don't have a test file for I do see we have a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could add a test for this function, but I don't really know what input values it would actually receive. I'm not quite sure when the function should be returning
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quick query is a feature where the IDE generates a bare-bones qlpack in a temporary directory that is tailored to the current language. It is meant to be semi-ephemeral. When you call the quick query command, the extension checks if the query query pack exists already and if it is for the correct language of the current database. |
||
| if (!(await pathExists(qlPackFile))) { | ||
| return true; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have a test for this new function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 , I've added a test for this function. I've also moved the function to the
puredirectory because this doesn't actually need VSCode and that makes it clearer that this can be a unit test.