Skip to content

Commit 04b8681

Browse files
authored
Merge pull request #1184 from github/aeisenberg/open-remote
Add command to open remote query on github
2 parents b510b85 + d5549f2 commit 04b8681

2 files changed

Lines changed: 42 additions & 2 deletions

File tree

extensions/ql-vscode/package.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,10 @@
544544
"command": "codeQLQueryHistory.compareWith",
545545
"title": "Compare Results"
546546
},
547+
{
548+
"command": "codeQLQueryHistory.openOnGithub",
549+
"title": "Open Remote Query on GitHub"
550+
},
547551
{
548552
"command": "codeQLQueryResults.nextPathStep",
549553
"title": "CodeQL: Show Next Step on Path"
@@ -734,7 +738,12 @@
734738
{
735739
"command": "codeQLQueryHistory.cancel",
736740
"group": "9_qlCommands",
737-
"when": "viewItem == inProgressResultsItem"
741+
"when": "viewItem == inProgressResultsItem || viewItem == inProgressRemoteResultsItem"
742+
},
743+
{
744+
"command": "codeQLQueryHistory.openOnGithub",
745+
"group": "9_qlCommands",
746+
"when": "viewItem == remoteResultsItem || viewItem == inProgressRemoteResultsItem"
738747
},
739748
{
740749
"command": "codeQLTests.showOutputDifferences",
@@ -904,6 +913,10 @@
904913
"command": "codeQLQueryHistory.cancel",
905914
"when": "false"
906915
},
916+
{
917+
"command": "codeQLQueryHistory.openOnGithub",
918+
"when": "false"
919+
},
907920
{
908921
"command": "codeQLQueryHistory.showQueryText",
909922
"when": "false"

extensions/ql-vscode/src/query-history.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class HistoryTreeDataProvider extends DisposableObject {
151151
switch (element.status) {
152152
case QueryStatus.InProgress:
153153
treeItem.iconPath = new ThemeIcon('sync~spin');
154-
treeItem.contextValue = 'inProgressResultsItem';
154+
treeItem.contextValue = element.t === 'local' ? 'inProgressResultsItem' : 'inProgressRemoteResultsItem';
155155
break;
156156
case QueryStatus.Completed:
157157
if (element.t === 'local') {
@@ -450,6 +450,14 @@ export class QueryHistoryManager extends DisposableObject {
450450
}
451451
)
452452
);
453+
this.push(
454+
commandRunner(
455+
'codeQLQueryHistory.openOnGithub',
456+
async (item: LocalQueryInfo) => {
457+
return this.handleOpenOnGithub(item, [item]);
458+
}
459+
)
460+
);
453461

454462
// There are two configuration items that affect the query history:
455463
// 1. The ttl for query history items.
@@ -856,6 +864,25 @@ export class QueryHistoryManager extends DisposableObject {
856864
);
857865
}
858866

867+
async handleOpenOnGithub(
868+
singleItem: QueryHistoryInfo,
869+
multiSelect: QueryHistoryInfo[],
870+
) {
871+
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);
872+
873+
// Remote queries only
874+
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem || finalSingleItem.t !== 'remote') {
875+
return;
876+
}
877+
878+
const { actionsWorkflowRunId: workflowRunId, controllerRepository: { owner, name } } = finalSingleItem.remoteQuery;
879+
880+
await commands.executeCommand(
881+
'vscode.open',
882+
Uri.parse(`https://github.com/${owner}/${name}/actions/runs/${workflowRunId}`)
883+
);
884+
}
885+
859886
async getQueryText(item: QueryHistoryInfo): Promise<string> {
860887
return item.t === 'local'
861888
? item.initialInfo.queryText

0 commit comments

Comments
 (0)