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
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
"title": "Open File in GitHub",
"category": "GitHub Pull Requests"
},
{
"command": "pr.copyCommitHash",
"title": "Copy Commit Hash",
"category": "GitHub Pull Requests"
},
{
"command": "pr.openDiffView",
"title": "Open Diff View",
Expand Down Expand Up @@ -335,6 +340,10 @@
{
"command": "pr.signinAndRefreshList",
"when": "false"
},
{
"command": "pr.copyCommitHash",
"when": "false"
}
],
"view/title": [
Expand Down Expand Up @@ -379,6 +388,10 @@
"command": "pr.openFileInGitHub",
"when": "view =~ /(pr|prStatus)/ && viewItem =~ /filechange/"
},
{
"command": "pr.copyCommitHash",
"when": "view == prStatus && viewItem =~ /commit/"
},
{
"command": "pr.openDescriptionToTheSide",
"group": "inline",
Expand Down
5 changes: 5 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ReviewManager } from './view/reviewManager';
import { PullRequestOverviewPanel } from './github/pullRequestOverview';
import { fromReviewUri, ReviewUriParams } from './common/uri';
import { GitFileChangeNode, InMemFileChangeNode } from './view/treeNodes/fileChangeNode';
import { CommitNode } from './view/treeNodes/commitNode';
import { PRNode } from './view/treeNodes/pullRequestNode';
import { ITelemetry, PullRequest } from './github/interface';
import { formatError } from './common/utils';
Expand Down Expand Up @@ -132,6 +133,10 @@ export function registerCommands(context: vscode.ExtensionContext, prManager: Pu
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(e.blobUrl!));
}));

context.subscriptions.push(vscode.commands.registerCommand('pr.copyCommitHash', (e: CommitNode) => {
vscode.env.clipboard.writeText(e.sha);
}));

context.subscriptions.push(vscode.commands.registerCommand('pr.openDiffView', (fileChangeNode: GitFileChangeNode | InMemFileChangeNode) => {
const parentFilePath = fileChangeNode.parentFilePath;
const filePath = fileChangeNode.filePath;
Expand Down
5 changes: 4 additions & 1 deletion src/view/treeNodes/commitNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import { PullRequestModel } from '../../github/pullRequestModel';

export class CommitNode extends TreeNode implements vscode.TreeItem {
public label: string;
public sha: string;
public collapsibleState: vscode.TreeItemCollapsibleState;
public iconPath: vscode.Uri | undefined;
public contextValue?: string;

constructor(
public parent: TreeNode | vscode.TreeView<TreeNode>,
Expand All @@ -28,8 +30,8 @@ export class CommitNode extends TreeNode implements vscode.TreeItem {
) {
super();
this.label = commit.commit.message;
this.sha = commit.sha;
this.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed;

let userIconUri: vscode.Uri | undefined;
try {
if (commit.author && commit.author.avatar_url) {
Expand All @@ -40,6 +42,7 @@ export class CommitNode extends TreeNode implements vscode.TreeItem {
}

this.iconPath = userIconUri;
this.contextValue = 'commit';
}

getTreeItem(): vscode.TreeItem {
Expand Down