Merge remote-tracking branch 'origin/main' into koesie10/mocked-config
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
## [UNRELEASED]
|
||||
|
||||
- Renamed command "CodeQL: Run Query" to "CodeQL: Run Query on Selected Dababase".
|
||||
## 1.7.8 - 2 February 2023
|
||||
|
||||
- Renamed command "CodeQL: Run Query" to "CodeQL: Run Query on Selected Database". [#1962](https://github.com/github/vscode-codeql/pull/1962)
|
||||
- Remove support for CodeQL CLI versions older than 2.7.6. [#1788](https://github.com/github/vscode-codeql/pull/1788)
|
||||
|
||||
## 1.7.7 - 13 December 2022
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"$schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"version": {
|
||||
"type": "integer"
|
||||
},
|
||||
"databases": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -119,6 +122,6 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": ["databases"],
|
||||
"required": ["databases", "version"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
|
||||
4
extensions/ql-vscode/package-lock.json
generated
4
extensions/ql-vscode/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "vscode-codeql",
|
||||
"version": "1.7.8",
|
||||
"version": "1.7.9",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "vscode-codeql",
|
||||
"version": "1.7.8",
|
||||
"version": "1.7.9",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "CodeQL for Visual Studio Code",
|
||||
"author": "GitHub",
|
||||
"private": true,
|
||||
"version": "1.7.8",
|
||||
"version": "1.7.9",
|
||||
"publisher": "GitHub",
|
||||
"license": "MIT",
|
||||
"icon": "media/VS-marketplace-CodeQL-icon.png",
|
||||
|
||||
@@ -638,3 +638,16 @@ export class MockGitHubApiConfigListener
|
||||
export function getMockGitHubApiServerScenariosPath(): string | undefined {
|
||||
return MOCK_GH_API_SERVER_SCENARIOS_PATH.getValue<string>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables features that are specific to the codespaces-codeql template workspace from
|
||||
* https://github.com/github/codespaces-codeql.
|
||||
*/
|
||||
export const CODESPACES_TEMPLATE = new Setting(
|
||||
"codespacesTemplate",
|
||||
ROOT_SETTING,
|
||||
);
|
||||
|
||||
export function isCodespacesTemplate() {
|
||||
return !!CODESPACES_TEMPLATE.getValue<boolean>();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
CancellationToken,
|
||||
ThemeIcon,
|
||||
ThemeColor,
|
||||
workspace,
|
||||
} from "vscode";
|
||||
import { pathExists, stat, readdir, remove } from "fs-extra";
|
||||
|
||||
@@ -218,6 +219,15 @@ export class DatabaseUI extends DisposableObject {
|
||||
},
|
||||
),
|
||||
);
|
||||
this.push(
|
||||
commandRunnerWithProgress(
|
||||
"codeQL.setDefaultTourDatabase",
|
||||
this.handleSetDefaultTourDatabase,
|
||||
{
|
||||
title: "Set Default Database for Codespace CodeQL Tour",
|
||||
},
|
||||
),
|
||||
);
|
||||
this.push(
|
||||
commandRunnerWithProgress(
|
||||
"codeQL.upgradeCurrentDatabase",
|
||||
@@ -348,6 +358,40 @@ export class DatabaseUI extends DisposableObject {
|
||||
}
|
||||
};
|
||||
|
||||
private handleSetDefaultTourDatabase = async (
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void> => {
|
||||
try {
|
||||
if (!workspace.workspaceFolders?.length) {
|
||||
throw new Error("No workspace folder is open.");
|
||||
} else {
|
||||
// This specifically refers to the database folder in
|
||||
// https://github.com/github/codespaces-codeql
|
||||
const uri = Uri.parse(
|
||||
`${workspace.workspaceFolders[0].uri}/codeql-tutorial-database`,
|
||||
);
|
||||
|
||||
let databaseItem = this.databaseManager.findDatabaseItem(uri);
|
||||
if (databaseItem === undefined) {
|
||||
databaseItem = await this.databaseManager.openDatabase(
|
||||
progress,
|
||||
token,
|
||||
uri,
|
||||
);
|
||||
}
|
||||
await this.databaseManager.setCurrentDatabaseItem(databaseItem);
|
||||
}
|
||||
} catch (e) {
|
||||
// rethrow and let this be handled by default error handling.
|
||||
throw new Error(
|
||||
`Could not set the database for the Code Tour. Please make sure you are using the default workspace in your codespace: ${getErrorMessage(
|
||||
e,
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
handleRemoveOrphanedDatabases = async (): Promise<void> => {
|
||||
void extLogger.log("Removing orphaned databases from workspace storage.");
|
||||
let dbDirs = undefined;
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
renameLocalList,
|
||||
renameRemoteList,
|
||||
SelectedDbItem,
|
||||
DB_CONFIG_VERSION,
|
||||
} from "./db-config";
|
||||
import * as chokidar from "chokidar";
|
||||
import { DisposableObject, DisposeHandler } from "../../pure/disposable-object";
|
||||
@@ -459,6 +460,7 @@ export class DbConfigStore extends DisposableObject {
|
||||
|
||||
private createEmptyConfig(): DbConfig {
|
||||
return {
|
||||
version: DB_CONFIG_VERSION,
|
||||
databases: {
|
||||
variantAnalysis: {
|
||||
repositoryLists: [],
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// Contains models for the data we want to store in the database config
|
||||
// Contains models and consts for the data we want to store in the database config.
|
||||
// Changes to these models should be done carefully and account for backwards compatibility of data.
|
||||
|
||||
export const DB_CONFIG_VERSION = 1;
|
||||
|
||||
export interface DbConfig {
|
||||
version: number;
|
||||
databases: DbConfigDatabases;
|
||||
selected?: SelectedDbItem;
|
||||
}
|
||||
@@ -89,6 +93,7 @@ export interface LocalDatabase {
|
||||
|
||||
export function cloneDbConfig(config: DbConfig): DbConfig {
|
||||
return {
|
||||
version: config.version,
|
||||
databases: {
|
||||
variantAnalysis: {
|
||||
repositoryLists: config.databases.variantAnalysis.repositoryLists.map(
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
LocalList,
|
||||
RemoteRepositoryList,
|
||||
SelectedDbItem,
|
||||
DB_CONFIG_VERSION,
|
||||
} from "../../src/databases/config/db-config";
|
||||
|
||||
export function createDbConfig({
|
||||
@@ -23,6 +24,7 @@ export function createDbConfig({
|
||||
selected?: SelectedDbItem;
|
||||
} = {}): DbConfig {
|
||||
return {
|
||||
version: DB_CONFIG_VERSION,
|
||||
databases: {
|
||||
variantAnalysis: {
|
||||
repositoryLists: remoteLists,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"version": 1,
|
||||
"databases": {
|
||||
"variantAnalysis": {
|
||||
"repositoryLists": [
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"version": 1,
|
||||
"databases": {
|
||||
"variantAnalysis": {
|
||||
"repositoryLists": [],
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { join } from "path";
|
||||
import { DbConfig } from "../../../../src/databases/config/db-config";
|
||||
import {
|
||||
DbConfig,
|
||||
DB_CONFIG_VERSION,
|
||||
} from "../../../../src/databases/config/db-config";
|
||||
import { DbConfigValidator } from "../../../../src/databases/config/db-config-validator";
|
||||
import { DbConfigValidationErrorKind } from "../../../../src/databases/db-validation-errors";
|
||||
import {
|
||||
@@ -15,6 +18,7 @@ describe("db config validation", () => {
|
||||
// We're intentionally bypassing the type check because we'd
|
||||
// like to make sure validation errors are highlighted.
|
||||
const dbConfig = {
|
||||
version: DB_CONFIG_VERSION,
|
||||
databases: {
|
||||
variantAnalysis: {
|
||||
repositoryLists: [
|
||||
|
||||
@@ -413,6 +413,7 @@ describe("db manager", () => {
|
||||
const dbConfigFileContents = await readDbConfigDirectly();
|
||||
|
||||
expect(dbConfigFileContents).toEqual({
|
||||
version: dbConfig.version,
|
||||
databases: {
|
||||
variantAnalysis: {
|
||||
repositoryLists: [],
|
||||
@@ -434,6 +435,7 @@ describe("db manager", () => {
|
||||
const dbConfigFileContents = await readDbConfigDirectly();
|
||||
|
||||
expect(dbConfigFileContents).toEqual({
|
||||
version: dbConfig.version,
|
||||
databases: {
|
||||
variantAnalysis: {
|
||||
repositoryLists: [remoteList],
|
||||
@@ -459,6 +461,7 @@ describe("db manager", () => {
|
||||
const dbConfigFileContents = await readDbConfigDirectly();
|
||||
|
||||
expect(dbConfigFileContents).toEqual({
|
||||
version: dbConfig.version,
|
||||
databases: {
|
||||
variantAnalysis: {
|
||||
repositoryLists: [remoteList],
|
||||
@@ -484,6 +487,7 @@ describe("db manager", () => {
|
||||
const dbConfigFileContents = await readDbConfigDirectly();
|
||||
|
||||
expect(dbConfigFileContents).toEqual({
|
||||
version: dbConfig.version,
|
||||
databases: {
|
||||
variantAnalysis: {
|
||||
repositoryLists: [remoteList],
|
||||
@@ -513,6 +517,7 @@ describe("db manager", () => {
|
||||
const dbConfigFileContents = await readDbConfigDirectly();
|
||||
|
||||
expect(dbConfigFileContents).toEqual({
|
||||
version: dbConfig.version,
|
||||
databases: {
|
||||
variantAnalysis: {
|
||||
repositoryLists: [remoteList],
|
||||
|
||||
@@ -15,7 +15,7 @@ jest.setTimeout(60_000);
|
||||
/**
|
||||
* Run various integration tests for databases
|
||||
*/
|
||||
describe("Databases", () => {
|
||||
describe("DatabaseFetcher", () => {
|
||||
let databaseManager: DatabaseManager;
|
||||
let inputBoxStub: jest.SpiedFunction<typeof window.showInputBox>;
|
||||
let cli: CodeQLCliServer;
|
||||
@@ -49,39 +49,44 @@ describe("Databases", () => {
|
||||
await cleanDatabases(databaseManager);
|
||||
});
|
||||
|
||||
it("should add a database from a folder", async () => {
|
||||
const uri = Uri.file(dbLoc);
|
||||
let dbItem = await importArchiveDatabase(
|
||||
uri.toString(true),
|
||||
databaseManager,
|
||||
storagePath,
|
||||
progressCallback,
|
||||
{} as CancellationToken,
|
||||
cli,
|
||||
);
|
||||
expect(dbItem).toBe(databaseManager.currentDatabaseItem);
|
||||
expect(dbItem).toBe(databaseManager.databaseItems[0]);
|
||||
expect(dbItem).toBeDefined();
|
||||
dbItem = dbItem!;
|
||||
expect(dbItem.name).toBe("db");
|
||||
expect(dbItem.databaseUri.fsPath).toBe(join(storagePath, "db", "db"));
|
||||
describe("importArchiveDatabase", () => {
|
||||
it("should add a database from a folder", async () => {
|
||||
const uri = Uri.file(dbLoc);
|
||||
let dbItem = await importArchiveDatabase(
|
||||
uri.toString(true),
|
||||
databaseManager,
|
||||
storagePath,
|
||||
progressCallback,
|
||||
{} as CancellationToken,
|
||||
cli,
|
||||
);
|
||||
expect(dbItem).toBe(databaseManager.currentDatabaseItem);
|
||||
expect(dbItem).toBe(databaseManager.databaseItems[0]);
|
||||
expect(dbItem).toBeDefined();
|
||||
dbItem = dbItem!;
|
||||
expect(dbItem.name).toBe("db");
|
||||
expect(dbItem.databaseUri.fsPath).toBe(join(storagePath, "db", "db"));
|
||||
});
|
||||
});
|
||||
|
||||
it("should add a database from a url", async () => {
|
||||
inputBoxStub.mockResolvedValue(DB_URL);
|
||||
describe("promptImportInternetDatabase", () => {
|
||||
it("should add a database from a url", async () => {
|
||||
// Provide a database URL when prompted
|
||||
inputBoxStub.mockResolvedValue(DB_URL);
|
||||
|
||||
let dbItem = await promptImportInternetDatabase(
|
||||
databaseManager,
|
||||
storagePath,
|
||||
progressCallback,
|
||||
{} as CancellationToken,
|
||||
cli,
|
||||
);
|
||||
expect(dbItem).toBeDefined();
|
||||
dbItem = dbItem!;
|
||||
expect(dbItem.name).toBe("db");
|
||||
expect(dbItem.databaseUri.fsPath).toBe(
|
||||
join(storagePath, "simple-db", "db"),
|
||||
);
|
||||
let dbItem = await promptImportInternetDatabase(
|
||||
databaseManager,
|
||||
storagePath,
|
||||
progressCallback,
|
||||
{} as CancellationToken,
|
||||
cli,
|
||||
);
|
||||
expect(dbItem).toBeDefined();
|
||||
dbItem = dbItem!;
|
||||
expect(dbItem.name).toBe("db");
|
||||
expect(dbItem.databaseUri.fsPath).toBe(
|
||||
join(storagePath, "simple-db", "db"),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -459,7 +459,7 @@ describe("QueryHistoryManager", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("should change the selection", () => {
|
||||
it.skip("should change the selection", () => {
|
||||
expect(queryHistoryManager.treeDataProvider.getCurrent()).toBe(
|
||||
newSelected,
|
||||
);
|
||||
@@ -561,7 +561,7 @@ describe("QueryHistoryManager", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("should change the selection", () => {
|
||||
it.skip("should change the selection", () => {
|
||||
expect(queryHistoryManager.treeDataProvider.getCurrent()).toEqual(
|
||||
newSelected,
|
||||
);
|
||||
@@ -1272,7 +1272,7 @@ describe("QueryHistoryManager", () => {
|
||||
await p;
|
||||
});
|
||||
|
||||
it("should get the selection from the treeDataProvider when both selections and the treeView are empty", async () => {
|
||||
it.skip("should get the selection from the treeDataProvider when both selections and the treeView are empty", async () => {
|
||||
queryHistoryManager = await createMockQueryHistory(allHistory);
|
||||
await queryHistoryManager.treeView.reveal(allHistory[1], {
|
||||
select: true,
|
||||
|
||||
Reference in New Issue
Block a user