Skip to content

Commit 420fd8d

Browse files
Merge branch 'main' into robertbrignull/logged_error_telemetry
2 parents 05d9f9b + a901369 commit 420fd8d

38 files changed

Lines changed: 173 additions & 86 deletions

extensions/ql-vscode/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ const baseConfig = {
4949
"@typescript-eslint/no-throw-literal": "error",
5050
"no-useless-escape": 0,
5151
camelcase: "off",
52-
eqeqeq: "off",
5352
"escompat/no-regexp-lookbehind": "off",
5453
"etc/no-implicit-any-catch": "error",
5554
"filenames/match-regex": "off",

extensions/ql-vscode/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
## [UNRELEASED]
44

5-
- Renamed command "CodeQL: Run Query" to "CodeQL: Run Query on Selected Dababase".
5+
## 1.7.8 - 2 February 2023
6+
7+
- Renamed command "CodeQL: Run Query" to "CodeQL: Run Query on Selected Database". [#1962](https://github.com/github/vscode-codeql/pull/1962)
68
- Remove support for CodeQL CLI versions older than 2.7.6. [#1788](https://github.com/github/vscode-codeql/pull/1788)
79

810
## 1.7.7 - 13 December 2022

extensions/ql-vscode/databases-schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"$schema": {
55
"type": "string"
66
},
7+
"version": {
8+
"type": "integer"
9+
},
710
"databases": {
811
"type": "object",
912
"properties": {
@@ -119,6 +122,6 @@
119122
]
120123
}
121124
},
122-
"required": ["databases"],
125+
"required": ["databases", "version"],
123126
"additionalProperties": false
124127
}

extensions/ql-vscode/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/ql-vscode/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "CodeQL for Visual Studio Code",
55
"author": "GitHub",
66
"private": true,
7-
"version": "1.7.8",
7+
"version": "1.7.9",
88
"publisher": "GitHub",
99
"license": "MIT",
1010
"icon": "media/VS-marketplace-CodeQL-icon.png",
@@ -1483,7 +1483,7 @@
14831483
"husky": {
14841484
"hooks": {
14851485
"pre-commit": "npm run format-staged",
1486-
"pre-push": "npm run lint && scripts/forbid-test-only"
1486+
"pre-push": "scripts/forbid-test-only"
14871487
}
14881488
},
14891489
"lint-staged": {

extensions/ql-vscode/src/abstract-webview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export abstract class AbstractWebview<
5151
}
5252

5353
protected async getPanel(): Promise<WebviewPanel> {
54-
if (this.panel == undefined) {
54+
if (this.panel === undefined) {
5555
const { ctx } = this;
5656

5757
// This is an async method, so in theory this method can be called concurrently. To ensure that we don't

extensions/ql-vscode/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ export class CodeQLCliServer implements Disposable {
384384
this.killProcessIfRunning();
385385
// Report the error (if there is a stderr then use that otherwise just report the error cod or nodejs error)
386386
const newError =
387-
stderrBuffers.length == 0
387+
stderrBuffers.length === 0
388388
? new Error(`${description} failed: ${err}`)
389389
: new Error(
390390
`${description} failed: ${Buffer.concat(stderrBuffers).toString(

extensions/ql-vscode/src/config.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ export class QueryServerConfigListener
357357
if (memory === null) {
358358
return undefined;
359359
}
360-
if (memory == 0 || typeof memory !== "number") {
360+
if (memory === 0 || typeof memory !== "number") {
361361
void extLogger.log(
362362
`Ignoring value '${memory}' for setting ${MEMORY_SETTING.qualifiedName}`,
363363
);
@@ -647,3 +647,16 @@ export class MockGitHubApiConfigListener
647647
export function getMockGitHubApiServerScenariosPath(): string | undefined {
648648
return MOCK_GH_API_SERVER_SCENARIOS_PATH.getValue<string>();
649649
}
650+
651+
/**
652+
* Enables features that are specific to the codespaces-codeql template workspace from
653+
* https://github.com/github/codespaces-codeql.
654+
*/
655+
export const CODESPACES_TEMPLATE = new Setting(
656+
"codespacesTemplate",
657+
ROOT_SETTING,
658+
);
659+
660+
export function isCodespacesTemplate() {
661+
return !!CODESPACES_TEMPLATE.getValue<boolean>();
662+
}

extensions/ql-vscode/src/contextual/locationFinder.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ function createTemplates(path: string): Record<string, string> {
128128
function isValidSelect(selectInfo: ResultSetSchema | undefined) {
129129
return (
130130
selectInfo &&
131-
selectInfo.columns.length == 3 &&
132-
selectInfo.columns[0].kind == ColumnKindCode.ENTITY &&
133-
selectInfo.columns[1].kind == ColumnKindCode.ENTITY &&
134-
selectInfo.columns[2].kind == ColumnKindCode.STRING
131+
selectInfo.columns.length === 3 &&
132+
selectInfo.columns[0].kind === ColumnKindCode.ENTITY &&
133+
selectInfo.columns[1].kind === ColumnKindCode.ENTITY &&
134+
selectInfo.columns[2].kind === ColumnKindCode.STRING
135135
);
136136
}

extensions/ql-vscode/src/databases-ui.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
CancellationToken,
1313
ThemeIcon,
1414
ThemeColor,
15+
workspace,
1516
} from "vscode";
1617
import { pathExists, stat, readdir, remove } from "fs-extra";
1718

@@ -220,6 +221,15 @@ export class DatabaseUI extends DisposableObject {
220221
},
221222
),
222223
);
224+
this.push(
225+
commandRunnerWithProgress(
226+
"codeQL.setDefaultTourDatabase",
227+
this.handleSetDefaultTourDatabase,
228+
{
229+
title: "Set Default Database for Codespace CodeQL Tour",
230+
},
231+
),
232+
);
223233
this.push(
224234
commandRunnerWithProgress(
225235
"codeQL.upgradeCurrentDatabase",
@@ -354,6 +364,40 @@ export class DatabaseUI extends DisposableObject {
354364
}
355365
};
356366

367+
private handleSetDefaultTourDatabase = async (
368+
progress: ProgressCallback,
369+
token: CancellationToken,
370+
): Promise<void> => {
371+
try {
372+
if (!workspace.workspaceFolders?.length) {
373+
throw new Error("No workspace folder is open.");
374+
} else {
375+
// This specifically refers to the database folder in
376+
// https://github.com/github/codespaces-codeql
377+
const uri = Uri.parse(
378+
`${workspace.workspaceFolders[0].uri}/codeql-tutorial-database`,
379+
);
380+
381+
let databaseItem = this.databaseManager.findDatabaseItem(uri);
382+
if (databaseItem === undefined) {
383+
databaseItem = await this.databaseManager.openDatabase(
384+
progress,
385+
token,
386+
uri,
387+
);
388+
}
389+
await this.databaseManager.setCurrentDatabaseItem(databaseItem);
390+
}
391+
} catch (e) {
392+
// rethrow and let this be handled by default error handling.
393+
throw new Error(
394+
`Could not set the database for the Code Tour. Please make sure you are using the default workspace in your codespace: ${getErrorMessage(
395+
e,
396+
)}`,
397+
);
398+
}
399+
};
400+
357401
handleRemoveOrphanedDatabases = async (): Promise<void> => {
358402
void extLogger.log("Removing orphaned databases from workspace storage.");
359403
let dbDirs = undefined;

0 commit comments

Comments
 (0)