Skip to content

Commit d618a4e

Browse files
Merge pull request #2080 from github/shati-elena/fix-database-prompt
Don't offer to create skeleton pack for default database in CodeTour
2 parents feac82f + 397be15 commit d618a4e

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,14 @@ export class DatabaseUI extends DisposableObject {
379379
);
380380

381381
let databaseItem = this.databaseManager.findDatabaseItem(uri);
382+
const isTutorialDatabase = true;
382383
if (databaseItem === undefined) {
383384
databaseItem = await this.databaseManager.openDatabase(
384385
progress,
385386
token,
386387
uri,
388+
"CodeQL Tutorial Database",
389+
isTutorialDatabase,
387390
);
388391
}
389392
await this.databaseManager.setCurrentDatabaseItem(databaseItem);

extensions/ql-vscode/src/databases.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@ export class DatabaseManager extends DisposableObject {
606606
token: vscode.CancellationToken,
607607
uri: vscode.Uri,
608608
displayName?: string,
609+
isTutorialDatabase?: boolean,
609610
): Promise<DatabaseItem> {
610611
const contents = await DatabaseResolver.resolveDatabaseContents(uri);
611612
// Ignore the source archive for QLTest databases by default.
@@ -629,7 +630,7 @@ export class DatabaseManager extends DisposableObject {
629630
await this.addDatabaseItem(progress, token, databaseItem);
630631
await this.addDatabaseSourceArchiveFolder(databaseItem);
631632

632-
if (isCodespacesTemplate()) {
633+
if (isCodespacesTemplate() && !isTutorialDatabase) {
633634
await this.createSkeletonPacks(databaseItem);
634635
}
635636

extensions/ql-vscode/test/vscode-tests/minimal-workspace/databases.test.ts

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -711,16 +711,36 @@ describe("databases", () => {
711711
});
712712

713713
describe("when codeQL.codespacesTemplate is set to true", () => {
714-
it("should create a skeleton QL pack", async () => {
715-
jest.spyOn(Setting.prototype, "getValue").mockReturnValue(true);
714+
describe("when we add the tutorial database to the codespace", () => {
715+
it("should not offer to create a skeleton QL pack", async () => {
716+
jest.spyOn(Setting.prototype, "getValue").mockReturnValue(true);
716717

717-
await databaseManager.openDatabase(
718-
{} as ProgressCallback,
719-
{} as CancellationToken,
720-
mockDbItem.databaseUri,
721-
);
718+
const isTutorialDatabase = true;
719+
720+
await databaseManager.openDatabase(
721+
{} as ProgressCallback,
722+
{} as CancellationToken,
723+
mockDbItem.databaseUri,
724+
"CodeQL Tutorial Database",
725+
isTutorialDatabase,
726+
);
722727

723-
expect(createSkeletonPacksSpy).toBeCalledTimes(1);
728+
expect(createSkeletonPacksSpy).toBeCalledTimes(0);
729+
});
730+
});
731+
732+
describe("when we add a new database that isn't the tutorial one", () => {
733+
it("should create a skeleton QL pack", async () => {
734+
jest.spyOn(Setting.prototype, "getValue").mockReturnValue(true);
735+
736+
await databaseManager.openDatabase(
737+
{} as ProgressCallback,
738+
{} as CancellationToken,
739+
mockDbItem.databaseUri,
740+
);
741+
742+
expect(createSkeletonPacksSpy).toBeCalledTimes(1);
743+
});
724744
});
725745
});
726746

0 commit comments

Comments
 (0)