Skip to content

Commit b840d3f

Browse files
committed
Tidy up Gist creation
1 parent c829c30 commit b840d3f

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

extensions/ql-vscode/src/remote-queries/gh-actions-api-client.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ export async function createGist(
322322
files: { [key: string]: { content: string } }
323323
): Promise<string | undefined> {
324324
const octokit = await credentials.getOctokit();
325-
console.log(description, files);
326325
const response = await octokit.request('POST /gists', {
327326
description,
328327
files,

extensions/ql-vscode/src/remote-queries/remote-queries-interface.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,4 @@ export class RemoteQueriesInterfaceManager {
305305
fileSize: this.formatFileSize(analysisResult.fileSizeInBytes)
306306
}));
307307
}
308-
309-
/** Gets the current query ID */
310-
public getCurrentQueryId(): string | undefined {
311-
return this.currentQueryId;
312-
}
313308
}

extensions/ql-vscode/src/remote-queries/remote-queries-manager.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,19 +304,19 @@ export class RemoteQueriesManager extends DisposableObject {
304304
}
305305

306306
public async exportVariantAnalysisResults(): Promise<void> {
307-
const queryId = this.interfaceManager.getCurrentQueryId();
308307
const queryHistoryItem = this.qhm.getCurrentQueryHistoryItem();
309308

310-
if (!queryId || !queryHistoryItem || !queryHistoryItem.completed || queryHistoryItem.t !== 'remote') {
309+
if (!queryHistoryItem || queryHistoryItem.t !== 'remote') {
311310
throw new Error('No variant analysis results currently open. To open results, click an item in the query history view.');
311+
} else if (!queryHistoryItem.completed) {
312+
throw new Error('Variant analysis results are not yet available. Wait for results to be downloaded.');
312313
}
313314

315+
const queryId = queryHistoryItem.queryId;
314316
void this.logger.log(`Exporting variant analysis results for query: ${queryId}`);
315317
const query = queryHistoryItem.remoteQuery;
316318
const analysesResults = this.analysesResultsManager.getAnalysesResults(queryId);
317319

318-
const credentials = await Credentials.initialize(this.ctx);
319-
320320
const gistOption = {
321321
label: '$(ports-open-browser-icon) Create Gist (GitHub)',
322322
};
@@ -339,6 +339,7 @@ export class RemoteQueriesManager extends DisposableObject {
339339
}
340340

341341
if (exportFormat === gistOption) {
342+
const credentials = await Credentials.initialize(this.ctx);
342343
const description = 'CodeQL Variant Analysis Results';
343344

344345
const markdownFiles = generateMarkdown(query, analysesResults, 'gist');
@@ -350,7 +351,12 @@ export class RemoteQueriesManager extends DisposableObject {
350351
}, {} as { [key: string]: { content: string } });
351352

352353
const gistUrl = await createGist(credentials, description, gistFiles);
353-
void showAndLogInformationMessage(`Variant analysis results exported to [gist](${gistUrl}).`);
354+
if (gistUrl) {
355+
const shouldOpenGist = await showInformationMessageWithAction('Variant analysis results exported to gist.', 'Open gist');
356+
if (shouldOpenGist) {
357+
await commands.executeCommand('vscode.open', Uri.parse(gistUrl));
358+
}
359+
}
354360
} else if (exportFormat === localMarkdownOption) {
355361
// TODO: Write function that creates local markdown files
356362
// const markdownFiles = generateMarkdown(query, analysesResults, 'local');

0 commit comments

Comments
 (0)