Skip to content
Open
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
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,11 @@
"default": false,
"description": "%githubPullRequests.showPullRequestNumberInTree.description%"
},
"githubPullRequests.showCommitShaInTree": {
"type": "boolean",
"default": false,
"description": "%githubPullRequests.showCommitShaInTree.description%"
},
"githubPullRequests.pullRequestAvatarDisplay": {
"type": "string",
"enum": [
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"githubPullRequests.focusedMode.multiDiff": "Show all diffs in the pull request. If there are no changes, show the overview.",
"githubPullRequests.focusedMode.false": "Do not change the layout.",
"githubPullRequests.showPullRequestNumberInTree.description": "Shows the pull request number in the tree view.",
"githubPullRequests.showCommitShaInTree.description": "Shows the abbreviated commit SHA in the tree view",
"githubPullRequests.labelCreated.description": "Group of labels that you want to add to the pull request automatically. Labels that don't exist in the repository won't be added.",
"githubPullRequests.labelCreated.label.description": "Each string element is the value of label that you want to add.",
"githubPullRequests.pullRequestAvatarDisplay.description": "Which icon to use in the pull request tree view",
Expand Down
1 change: 1 addition & 0 deletions src/common/settingKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const CREATE_DRAFT = 'createDraft';
export const QUICK_DIFF = 'quickDiff';
export const SET_AUTO_MERGE = 'setAutoMerge';
export const SHOW_PULL_REQUEST_NUMBER_IN_TREE = 'showPullRequestNumberInTree';
export const SHOW_COMMIT_SHA_IN_TREE = 'showCommitShaInTree';
export const DEFAULT_MERGE_METHOD = 'defaultMergeMethod';
export const DEFAULT_DELETION_METHOD = 'defaultDeletionMethod';
export const SELECT_LOCAL_BRANCH = 'selectLocalBranch';
Expand Down
14 changes: 12 additions & 2 deletions src/view/treeNodes/commitNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as vscode from 'vscode';
import { getGitChangeType } from '../../common/diffHunk';
import { FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE } from '../../common/settingKeys';
import { FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE, SHOW_COMMIT_SHA_IN_TREE } from '../../common/settingKeys';
import { DataUri, reviewPath, toReviewUri } from '../../common/uri';
import { dateFromNow } from '../../common/utils';
import { OctokitCommon } from '../../github/common';
Expand Down Expand Up @@ -35,7 +35,17 @@ export class CommitNode extends TreeNode implements vscode.TreeItem {
this.sha = commit.sha;
this.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed;
this.contextValue = 'commit';
this.description = commit.commit.author?.date ? dateFromNow(commit.commit.author.date) : undefined;
this.description = this._getDescription();
}

private _getDescription(): string | undefined {
const date = this.commit.commit.author?.date ? dateFromNow(this.commit.commit.author.date) : undefined;
if (!vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<boolean>(SHOW_COMMIT_SHA_IN_TREE, false)) {
return date;
}
const shortSha = this.commit.sha.substring(0, 7);
return date ? `${shortSha} · ${date}` : shortSha;

}

async getTreeItem(): Promise<vscode.TreeItem> {
Expand Down
7 changes: 7 additions & 0 deletions src/view/treeNodes/commitsCategoryNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as vscode from 'vscode';
import { CommitNode } from './commitNode';
import { TreeNode, TreeNodeParent } from './treeNode';
import Logger, { PR_TREE } from '../../common/logger';
import { PR_SETTINGS_NAMESPACE, SHOW_COMMIT_SHA_IN_TREE } from '../../common/settingKeys';
import { createCommitsNodeUri } from '../../common/uri';
import { FolderRepositoryManager } from '../../github/folderRepositoryManager';
import { PullRequestModel } from '../../github/pullRequestModel';
Expand Down Expand Up @@ -42,6 +43,12 @@ export class CommitsNode extends TreeNode implements vscode.TreeItem {
this.refresh(this);
}
}));
this.childrenDisposables.push(vscode.workspace.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(`${PR_SETTINGS_NAMESPACE}.${SHOW_COMMIT_SHA_IN_TREE}`)) {
Logger.appendLine(`Commit Sha display setting has changed, refreshing Commits node`, PR_TREE);
this.refresh(this);
}
}));
}

getTreeItem(): vscode.TreeItem {
Expand Down