Skip to content

Commit 23a0e03

Browse files
committed
Completely remove using credentials in non-canary mode
This does not remove the previously added mechanism of not requesting credentials, but using them when they are available. I expect this to be used in the future.
1 parent 21c5ed0 commit 23a0e03

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

extensions/ql-vscode/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,10 @@
878878
}
879879
],
880880
"commandPalette": [
881+
{
882+
"command": "codeQL.authenticateToGitHub",
883+
"when": "config.codeQL.canary"
884+
},
881885
{
882886
"command": "codeQL.runQuery",
883887
"when": "resourceLangId == ql && resourceExtname == .ql"

extensions/ql-vscode/src/databaseFetcher.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { CodeQLCliServer } from './cli';
1111
import * as fs from 'fs-extra';
1212
import * as path from 'path';
1313
import * as Octokit from '@octokit/rest';
14+
import { retry } from '@octokit/plugin-retry';
1415

1516
import { DatabaseManager, DatabaseItem } from './databases';
1617
import {
@@ -24,7 +25,6 @@ import { logger } from './logging';
2425
import { tmpDir } from './helpers';
2526
import { Credentials } from './authentication';
2627
import { REPO_REGEX, getErrorMessage } from './pure/helpers-pure';
27-
import { isCanary } from './config';
2828

2929
/**
3030
* Prompts a user to fetch a database from a remote location. Database is assumed to be an archive file.
@@ -78,7 +78,7 @@ export async function promptImportInternetDatabase(
7878
export async function promptImportGithubDatabase(
7979
databaseManager: DatabaseManager,
8080
storagePath: string,
81-
credentials: Credentials,
81+
credentials: Credentials | undefined,
8282
progress: ProgressCallback,
8383
token: CancellationToken,
8484
cli?: CodeQLCliServer
@@ -101,8 +101,7 @@ export async function promptImportGithubDatabase(
101101
throw new Error(`Invalid GitHub repository: ${githubRepo}`);
102102
}
103103

104-
// Only require authentication if we are running with the canary flag enabled
105-
const octokit = await credentials.getOctokit(isCanary());
104+
const octokit = credentials ? await credentials.getOctokit(true) : new Octokit.Octokit({ retry });
106105

107106
const result = await convertGithubNwoToDatabaseUrl(githubRepo, octokit, progress);
108107
if (!result) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
import { CancellationToken } from 'vscode';
4141
import { asyncFilter, getErrorMessage } from './pure/helpers-pure';
4242
import { Credentials } from './authentication';
43+
import { isCanary } from './config';
4344

4445
type ThemableIconPath = { light: string; dark: string } | string;
4546

@@ -301,7 +302,7 @@ export class DatabaseUI extends DisposableObject {
301302
progress: ProgressCallback,
302303
token: CancellationToken
303304
) => {
304-
const credentials = await this.getCredentials();
305+
const credentials = isCanary() ? await this.getCredentials() : undefined;
305306
await this.handleChooseDatabaseGithub(credentials, progress, token);
306307
},
307308
{
@@ -480,7 +481,7 @@ export class DatabaseUI extends DisposableObject {
480481
};
481482

482483
handleChooseDatabaseGithub = async (
483-
credentials: Credentials,
484+
credentials: Credentials | undefined,
484485
progress: ProgressCallback,
485486
token: CancellationToken
486487
): Promise<DatabaseItem | undefined> => {

extensions/ql-vscode/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ async function activateWithInstalledDistribution(
970970
progress: ProgressCallback,
971971
token: CancellationToken
972972
) => {
973-
const credentials = await Credentials.initialize(ctx);
973+
const credentials = isCanary() ? await Credentials.initialize(ctx) : undefined;
974974
await databaseUI.handleChooseDatabaseGithub(credentials, progress, token);
975975
},
976976
{

0 commit comments

Comments
 (0)