Skip to content

Commit 11e64e3

Browse files
committed
Add ability to open PR diff as editor in VS Code
1 parent 938a11c commit 11e64e3

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ This extension contributes the following commands:
4545

4646
## Release Notes
4747

48+
### 2.0.2
49+
50+
Add ability to open the PR diff as an editor in VS Code. I highly recommend
51+
complementing this functionality with a plugin for viewing diff files, such as
52+
[Diff Viewer](
53+
https://marketplace.visualstudio.com/items?itemName=caponetto.vscode-diff-viewer).
54+
4855
### 2.0.1
4956

5057
Added "Collapse all" button to tree views.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openjdk-devel",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"displayName": "OpenJDK Development",
55
"description": "Support for OpenJDK developers",
66
"publisher": "magicus",

src/extension.ts

+5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ import * as vscode from 'vscode';
22

33
import { GitHubProvider } from './github';
44
import { JbsProvider } from './jbs';
5+
import { DownloadableContentProvider } from './downloading';
6+
7+
export const downloadableContentProvider = new DownloadableContentProvider('openjdk-dev-dl');
58

69
// this method is called when your extension is activated
710
// your extension is activated the very first time the command is executed
811
export function activate(context: vscode.ExtensionContext): void {
912
console.log('Loading extension "OpenJDK Development"');
1013

14+
downloadableContentProvider.register(context);
15+
1116
const githubProvider = new GitHubProvider();
1217
vscode.window.createTreeView('gitHubIntegration', {
1318
treeDataProvider: githubProvider,

src/github.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as vscode from 'vscode';
33

44
import { UpdatableProvider, UpdatableTreeItem } from './updatable';
55
import { JsonDownloader } from './downloading';
6+
import { downloadableContentProvider } from './extension';
67

78
class GitHubUpdatableDownloader extends JsonDownloader<GitHubTreeItem> {
89
public static gitHubApiBase: string = 'https://api.github.com/';
@@ -253,21 +254,27 @@ class PRTreeItem extends GitHubTreeItem {
253254
const prUrlBase = `https://github.com/${repo}/pull/${prNumber}`;
254255

255256
this.generated.push(new GitHubLeafTreeItem(`${repo}#${prNumber} by @${author}`, 'goto' + id,
256-
'github-overview.svg', prUrlBase, provider));
257+
'github-overview.svg', prUrlBase + '/files', provider));
257258

258259
const descItem = new GitHubLeafTreeItem(description.replace(/\s+/g, ' '), 'desc' + id,
259260
'github-conversation.svg', prUrlBase, provider);
260261
descItem.tooltip = new vscode.MarkdownString(description);
261262
this.generated.push(descItem);
262263

264+
var mainJbsIssue = undefined;
263265
for (const jbsIssue of jbsIssues) {
266+
if (mainJbsIssue === undefined) {
267+
mainJbsIssue = jbsIssue;
268+
}
264269
this.generated.push(new GitHubLeafTreeItem(jbsIssue, 'jbs' + id + '-' + jbsIssue,
265270
'github-bug.svg', 'https://bugs.openjdk.java.net/browse/' + jbsIssue, provider));
266271
}
267272

268273
// Diff description must be complemented from prUrl, which can only be done later
274+
const editorViewUrl = downloadableContentProvider.getDownloadableUrl(prUrlBase + '.diff',
275+
mainJbsIssue + '.diff');
269276
this.diffItem = new GitHubLeafTreeItem('Diff', 'diff' + id, 'github-diff.svg',
270-
prUrlBase + '/files', provider);
277+
editorViewUrl, provider);
271278
this.generated.push(this.diffItem);
272279

273280
if (tags) {

0 commit comments

Comments
 (0)