diff --git a/extensions/ql-vscode/src/remote-queries/gh-actions-api-client.ts b/extensions/ql-vscode/src/remote-queries/gh-actions-api-client.ts index 19a2a41df..f89af9276 100644 --- a/extensions/ql-vscode/src/remote-queries/gh-actions-api-client.ts +++ b/extensions/ql-vscode/src/remote-queries/gh-actions-api-client.ts @@ -322,7 +322,6 @@ export async function createGist( files: { [key: string]: { content: string } } ): Promise { const octokit = await credentials.getOctokit(); - console.log(description, files); const response = await octokit.request('POST /gists', { description, files, diff --git a/extensions/ql-vscode/src/remote-queries/remote-queries-interface.ts b/extensions/ql-vscode/src/remote-queries/remote-queries-interface.ts index 355358635..9ddc91f72 100644 --- a/extensions/ql-vscode/src/remote-queries/remote-queries-interface.ts +++ b/extensions/ql-vscode/src/remote-queries/remote-queries-interface.ts @@ -305,9 +305,4 @@ export class RemoteQueriesInterfaceManager { fileSize: this.formatFileSize(analysisResult.fileSizeInBytes) })); } - - /** Gets the current query ID */ - public getCurrentQueryId(): string | undefined { - return this.currentQueryId; - } } diff --git a/extensions/ql-vscode/src/remote-queries/remote-queries-manager.ts b/extensions/ql-vscode/src/remote-queries/remote-queries-manager.ts index 2d3108f3d..9ff21bc47 100644 --- a/extensions/ql-vscode/src/remote-queries/remote-queries-manager.ts +++ b/extensions/ql-vscode/src/remote-queries/remote-queries-manager.ts @@ -304,19 +304,19 @@ export class RemoteQueriesManager extends DisposableObject { } public async exportVariantAnalysisResults(): Promise { - const queryId = this.interfaceManager.getCurrentQueryId(); const queryHistoryItem = this.qhm.getCurrentQueryHistoryItem(); - if (!queryId || !queryHistoryItem || !queryHistoryItem.completed || queryHistoryItem.t !== 'remote') { + if (!queryHistoryItem || queryHistoryItem.t !== 'remote') { throw new Error('No variant analysis results currently open. To open results, click an item in the query history view.'); + } else if (!queryHistoryItem.completed) { + throw new Error('Variant analysis results are not yet available. Wait for results to be downloaded.'); } + const queryId = queryHistoryItem.queryId; void this.logger.log(`Exporting variant analysis results for query: ${queryId}`); const query = queryHistoryItem.remoteQuery; const analysesResults = this.analysesResultsManager.getAnalysesResults(queryId); - const credentials = await Credentials.initialize(this.ctx); - const gistOption = { label: '$(ports-open-browser-icon) Create Gist (GitHub)', }; @@ -339,6 +339,7 @@ export class RemoteQueriesManager extends DisposableObject { } if (exportFormat === gistOption) { + const credentials = await Credentials.initialize(this.ctx); const description = 'CodeQL Variant Analysis Results'; const markdownFiles = generateMarkdown(query, analysesResults, 'gist'); @@ -350,7 +351,12 @@ export class RemoteQueriesManager extends DisposableObject { }, {} as { [key: string]: { content: string } }); const gistUrl = await createGist(credentials, description, gistFiles); - void showAndLogInformationMessage(`Variant analysis results exported to [gist](${gistUrl}).`); + if (gistUrl) { + const shouldOpenGist = await showInformationMessageWithAction('Variant analysis results exported to gist.', 'Open gist'); + if (shouldOpenGist) { + await commands.executeCommand('vscode.open', Uri.parse(gistUrl)); + } + } } else if (exportFormat === localMarkdownOption) { // TODO: Write function that creates local markdown files // const markdownFiles = generateMarkdown(query, analysesResults, 'local');