Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into rebornix/navigate-d…
Browse files Browse the repository at this point in the history
…iffhunk-from-descriptionview
  • Loading branch information
rebornix committed Jan 5, 2019
2 parents b166f24 + da61b12 commit 4f51e6f
Show file tree
Hide file tree
Showing 21 changed files with 623 additions and 266 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
0.3.2
- Honor the new `git.openDiffOnClick` setting [#753](https://github.com/Microsoft/vscode-pull-request-github/pull/753)
- Prompt to stage all changes when running the suggest changes with nothing staged [#744](https://github.com/Microsoft/vscode-pull-request-github/pull/744)
- Add an inline "Open File" action in the "Changes in Pull Request" tree and match styling of git changes [#738](https://github.com/Microsoft/vscode-pull-request-github/pull/738)
- Display the full file path using the tree item's description, matching other views [#730](https://github.com/Microsoft/vscode-pull-request-github/issues/730)
- Parse auth callback state parameter on client side instead of mkaing a request to the auth server [#715](https://github.com/Microsoft/vscode-pull-request-github/pull/715)
- Fix [#735](https://github.com/Microsoft/vscode-pull-request-github/issues/735), ensure correct head parameter is used when creating PR
- Fix [#727](https://github.com/Microsoft/vscode-pull-request-github/issues/727), make sure review state is always cleared when switching branches
- Fix [#728](https://github.com/Microsoft/vscode-pull-request-github/issues/738), keep description page data up to date when updating title and description

0.3.1
- Add status check information on PR description page [#713](https://github.com/Microsoft/vscode-pull-request-github/pull/713)
- Add button for creating a pull request on PR tree view [#709](https://github.com/Microsoft/vscode-pull-request-github/pull/709)
Expand Down
43 changes: 41 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"enableProposedApi": true,
"preview": true,
"version": "0.3.1",
"version": "0.3.2",
"publisher": "GitHub",
"engines": {
"vscode": "^1.30.0"
Expand Down Expand Up @@ -176,6 +176,15 @@
{
"command": "pr.openDiffView",
"title": "Open Diff View",
"category": "GitHub Pull Requests",
"icon": {
"light": "resources/icons/light/open-change.svg",
"dark": "resources/icons/dark/open-change.svg"
}
},
{
"command": "pr.openChangedFile",
"title": "Open Changed File in PR",
"category": "GitHub Pull Requests"
},
{
Expand All @@ -184,6 +193,14 @@
"category": "GitHub Pull Requests",
"when": "github:inReviewMode"
},
{
"command": "pr.openDescriptionToTheSide",
"title": "Open Pull Request Description to the Side",
"icon": {
"light": "resources/icons/light/split-editor-horizontal.svg",
"dark": "resources/icons/dark/split-editor-horizontal-inverse.svg"
}
},
{
"command": "review.openFile",
"title": "Open File",
Expand Down Expand Up @@ -240,6 +257,10 @@
"command": "review.openFile",
"when": "false"
},
{
"command": "pr.openChangedFile",
"when": "false"
},
{
"command": "pr.close",
"when": "config.git.enabled && github:inReviewMode"
Expand Down Expand Up @@ -272,6 +293,10 @@
"command": "pr.openDiffView",
"when": "false"
},
{
"command": "pr.openDescriptionToTheSide",
"when": "false"
},
{
"command": "pr.openDescription",
"when": "config.git.enabled && github:inReviewMode"
Expand Down Expand Up @@ -335,10 +360,20 @@
"command": "pr.openFileInGitHub",
"when": "view =~ /(pr|prStatus)/ && viewItem =~ /filechange/"
},
{
"command": "pr.openDescriptionToTheSide",
"group": "inline",
"when": "view =~ /(pr|prStatus)/ && viewItem =~ /description/"
},
{
"command": "review.openFile",
"group": "inline",
"when": "view == prStatus && viewItem =~ /filechange(?!:DELETE)/"
"when": "config.git.openDiffOnClick && view == prStatus && viewItem =~ /filechange(?!:DELETE)/"
},
{
"command": "pr.openDiffView",
"group": "inline",
"when": "!config.git.openDiffOnClick && view == prStatus && viewItem =~ /filechange(?!:DELETE)/"
}
],
"editor/title": [
Expand Down Expand Up @@ -372,6 +407,7 @@
"@types/markdown-it": "^0.0.5",
"@types/mocha": "^5.2.2",
"@types/node": "*",
"@types/node-fetch": "^2.1.4",
"@types/query-string": "^6.1.1",
"@types/webpack": "^4.4.10",
"@types/ws": "^5.1.2",
Expand All @@ -394,10 +430,13 @@
},
"dependencies": {
"@octokit/rest": "^15.15.1",
"apollo-boost": "^0.1.22",
"apollo-link-context": "^1.0.12",
"axios": "^0.18.0",
"debounce": "^1.2.0",
"es6-promise": "^4.2.5",
"git-credential-node": "^1.1.0",
"graphql": "^14.0.2",
"iconv-lite": "0.4.23",
"js-base64": "^2.4.9",
"markdown-it": "^8.4.0",
Expand Down
8 changes: 8 additions & 0 deletions preview-src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const ElementIds = {
CheckoutDefaultBranch: 'checkout-default-branch',
Merge: 'merge',
Close: 'close',
Refresh: 'refresh',
Reply: 'reply',
Approve: 'approve',
RequestChanges: 'request-changes',
Expand Down Expand Up @@ -110,6 +111,7 @@ function setTitleHTML(pr: PullRequest): void {
<div class="button-group">
<button id="${ElementIds.Checkout}" aria-live="polite"></button>
<button id="${ElementIds.CheckoutDefaultBranch}" aria-live="polite">Exit Review Mode</button>
<button id="${ElementIds.Refresh}">Refresh</button>
</div>
</div>
<div class="subtitle">
Expand Down Expand Up @@ -235,6 +237,12 @@ function addEventListeners(pr: PullRequest): void {
}, 500);
});

document.getElementById(ElementIds.Refresh).addEventListener('click', () => {
messageHandler.postMessage({
command: 'pr.refresh'
});
});

document.getElementById(ElementIds.Reply)!.addEventListener('click', () => {
submitComment();
});
Expand Down
1 change: 1 addition & 0 deletions resources/icons/dark/split-editor-horizontal-inverse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions resources/icons/light/split-editor-horizontal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/authentication/githubServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class ResponseExpired extends Error {
get message() { return 'Token response expired'; }
}

const SEPARATOR = '/', SEPARATOR_LEN = SEPARATOR.length
const SEPARATOR = '/', SEPARATOR_LEN = SEPARATOR.length;

/**
* Hydrate and verify the signature of a message produced with `encode`
Expand Down
38 changes: 32 additions & 6 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as Github from '@octokit/rest';
import { ReviewManager } from './view/reviewManager';
import { PullRequestOverviewPanel } from './github/pullRequestOverview';
import { fromReviewUri, ReviewUriParams } from './common/uri';
import { GitFileChangeNode } from './view/treeNodes/fileChangeNode';
import { GitFileChangeNode, InMemFileChangeNode } from './view/treeNodes/fileChangeNode';
import { PRNode } from './view/treeNodes/pullRequestNode';
import { IPullRequestManager, IPullRequestModel, ITelemetry } from './github/interface';
import { formatError } from './common/utils';
Expand Down Expand Up @@ -63,12 +63,24 @@ export function registerCommands(context: vscode.ExtensionContext, prManager: IP

context.subscriptions.push(vscode.commands.registerCommand('review.suggestDiff', async (e) => {
try {
const diff = await prManager.repository.diff(true);
if (!diff) {
vscode.window.showWarningMessage('There are no staged changes for suggestions.');
return;
const { indexChanges, workingTreeChanges } = prManager.repository.state;

if (!indexChanges.length) {
if (workingTreeChanges.length) {
const stageAll = await vscode.window.showWarningMessage('There are no staged changes to suggest.\n\nWould you like to automatically stage all your of changes and suggest them?', { modal: true }, 'Yes');
if (stageAll === 'Yes') {
await vscode.commands.executeCommand('git.stageAll');
} else {
return;
}
} else {
vscode.window.showInformationMessage('There are no changes to suggest.');
return;
}
}

const diff = await prManager.repository.diff(true);

let suggestEditMessage = '';
if (e && e.inputBox && e.inputBox.value) {
suggestEditMessage = `${e.inputBox.value}\n`;
Expand Down Expand Up @@ -110,7 +122,13 @@ export function registerCommands(context: vscode.ExtensionContext, prManager: IP
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(e.blobUrl));
}));

context.subscriptions.push(vscode.commands.registerCommand('pr.openDiffView', (parentFilePath: string, filePath: string, fileName: string, isPartial: boolean, opts: any) => {
context.subscriptions.push(vscode.commands.registerCommand('pr.openDiffView', (fileChangeNode: GitFileChangeNode | InMemFileChangeNode) => {
const parentFilePath = fileChangeNode.parentFilePath;
const filePath = fileChangeNode.filePath;
const fileName = fileChangeNode.fileName;
const isPartial = fileChangeNode.isPartial;
const opts = fileChangeNode.opts;

if (isPartial) {
vscode.window.showInformationMessage('Your local repository is not up to date so only partial content is being displayed');
}
Expand Down Expand Up @@ -235,6 +253,14 @@ export function registerCommands(context: vscode.ExtensionContext, prManager: IP
telemetry.on('pr.openDescription');
}));

context.subscriptions.push(vscode.commands.registerCommand('pr.openDescriptionToTheSide', async (descriptionNode: DescriptionNode) => {
let pr = descriptionNode.pullRequestModel;
const pullRequest = ensurePR(prManager, pr);
// Create and show a new webview
PullRequestOverviewPanel.createOrShow(context.extensionPath, prManager, pullRequest, true);
telemetry.on('pr.openDescriptionToTheSide');
}));

context.subscriptions.push(vscode.commands.registerCommand('pr.viewChanges', async (fileChange: GitFileChangeNode) => {
if (fileChange.status === GitChangeType.DELETE || fileChange.status === GitChangeType.ADD) {
// create an empty `review` uri without any path/commit info.
Expand Down
3 changes: 2 additions & 1 deletion src/common/diffHunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as Github from '@octokit/rest';
import { GitChangeType, SlimFileChange, InMemFileChange } from './file';
import { Repository } from '../typings/git';
import { Comment } from './comment';
import { IRawFileChange } from '../github/interface';

export enum DiffChangeType {
Context,
Expand Down Expand Up @@ -253,7 +254,7 @@ export function getGitChangeType(status: string): GitChangeType {
}
}

export async function parseDiff(reviews: any[], repository: Repository, parentCommit: string): Promise<(InMemFileChange | SlimFileChange)[]> {
export async function parseDiff(reviews: IRawFileChange[], repository: Repository, parentCommit: string): Promise<(InMemFileChange | SlimFileChange)[]> {
let fileChanges: (InMemFileChange | SlimFileChange)[] = [];

for (let i = 0; i < reviews.length; i++) {
Expand Down
6 changes: 5 additions & 1 deletion src/common/uri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export interface PRUriParams {
}

export function fromPRUri(uri: Uri): PRUriParams {
return JSON.parse(uri.query);
try {
return JSON.parse(uri.query) as PRUriParams;
} catch (e) {
return null;
}
}

export interface GitUriOptions {
Expand Down
Loading

0 comments on commit 4f51e6f

Please sign in to comment.