Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions extensions/ql-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,15 @@ async function activateWithInstalledDistribution(
}),
);

ctx.subscriptions.push(
commandRunner(
"codeQL.openVariantAnalysisLogs",
async (variantAnalysisId: number) => {
await variantAnalysisManager.openVariantAnalysisLogs(variantAnalysisId);
},
),
);

ctx.subscriptions.push(
commandRunner(
"codeQL.copyVariantAnalysisRepoList",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { DisposableObject } from "../pure/disposable-object";
import { Credentials } from "../authentication";
import { VariantAnalysisMonitor } from "./variant-analysis-monitor";
import {
getActionsWorkflowRunUrl,
isVariantAnalysisComplete,
parseVariantAnalysisQueryLanguage,
VariantAnalysis,
Expand Down Expand Up @@ -585,6 +586,20 @@ export class VariantAnalysisManager
await cancelVariantAnalysis(credentials, variantAnalysis);
}

public async openVariantAnalysisLogs(variantAnalysisId: number) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add an integration test for this function, but it doesn't have to be part of this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll look at doing that in a followup

const variantAnalysis = this.variantAnalyses.get(variantAnalysisId);
if (!variantAnalysis) {
throw new Error(`No variant analysis with id: ${variantAnalysisId}`);
}

const actionsWorkflowRunUrl = getActionsWorkflowRunUrl(variantAnalysis);

await commands.executeCommand(
"vscode.open",
Uri.parse(actionsWorkflowRunUrl),
);
}

public async copyRepoListToClipboard(
variantAnalysisId: number,
filterSort: RepositoriesFilterSortStateWithIds = defaultFilterSortState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { commands, ExtensionContext, Uri, ViewColumn } from "vscode";
import { commands, ExtensionContext, ViewColumn } from "vscode";
import { AbstractWebview, WebviewPanelConfig } from "../abstract-webview";
import { extLogger } from "../common";
import {
Expand All @@ -7,7 +7,6 @@ import {
} from "../pure/interface-types";
import { assertNever } from "../pure/helpers-pure";
import {
getActionsWorkflowRunUrl,
VariantAnalysis,
VariantAnalysisScannedRepositoryResult,
VariantAnalysisScannedRepositoryState,
Expand Down Expand Up @@ -147,7 +146,10 @@ export class VariantAnalysisView
);
break;
case "openLogs":
await this.openLogs();
await commands.executeCommand(
"codeQL.openVariantAnalysisLogs",
this.variantAnalysisId,
);
break;
default:
assertNever(msg);
Expand Down Expand Up @@ -183,23 +185,4 @@ export class VariantAnalysisView
repoStates,
});
}

private async openLogs(): Promise<void> {
const variantAnalysis = await this.manager.getVariantAnalysis(
this.variantAnalysisId,
);
if (!variantAnalysis) {
void showAndLogWarningMessage(
"Could not open variant analysis logs. Variant analysis not found.",
);
return;
}

const actionsWorkflowRunUrl = getActionsWorkflowRunUrl(variantAnalysis);

await commands.executeCommand(
"vscode.open",
Uri.parse(actionsWorkflowRunUrl),
);
}
}