From f1e204fa52e4f516b32d474f4172cbab400df693 Mon Sep 17 00:00:00 2001 From: James Miller Date: Tue, 14 Jul 2026 02:08:24 +1000 Subject: [PATCH 1/3] Add setting to show commit SHAs in tree --- package.json | 5 +++++ package.nls.json | 1 + src/common/settingKeys.ts | 1 + src/view/treeNodes/commitNode.ts | 14 ++++++++++++-- src/view/treeNodes/commitsCategoryNode.ts | 7 +++++++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e33f921997..4ac5f1bde1 100644 --- a/package.json +++ b/package.json @@ -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": [ diff --git a/package.nls.json b/package.nls.json index ea64843094..44616d0c36 100644 --- a/package.nls.json +++ b/package.nls.json @@ -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", diff --git a/src/common/settingKeys.ts b/src/common/settingKeys.ts index 0f5e64399b..2e36d0b953 100644 --- a/src/common/settingKeys.ts +++ b/src/common/settingKeys.ts @@ -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'; diff --git a/src/view/treeNodes/commitNode.ts b/src/view/treeNodes/commitNode.ts index ee95b34a12..aca7201ae0 100644 --- a/src/view/treeNodes/commitNode.ts +++ b/src/view/treeNodes/commitNode.ts @@ -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'; @@ -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(SHOW_COMMIT_SHA_IN_TREE, false)) { + return date; + } + const shortSha = this.commit.sha.substring(0, 7); + return date ? `${shortSha} · ${date}` : shortSha; + } async getTreeItem(): Promise { diff --git a/src/view/treeNodes/commitsCategoryNode.ts b/src/view/treeNodes/commitsCategoryNode.ts index 7a0fb197ca..8151cecb64 100644 --- a/src/view/treeNodes/commitsCategoryNode.ts +++ b/src/view/treeNodes/commitsCategoryNode.ts @@ -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'; @@ -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 { From 6ec78779f7a5ea1715e86ebc9f63b7c371668c72 Mon Sep 17 00:00:00 2001 From: James Miller Date: Thu, 20 Aug 2026 14:17:43 +1000 Subject: [PATCH 2/3] Address review feedback: recompute description in getTreeItem and capitilsation + trailing period --- package.nls.json | 2 +- src/view/treeNodes/commitNode.ts | 2 +- src/view/treeNodes/commitsCategoryNode.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.nls.json b/package.nls.json index c6b892331b..51128db7f6 100644 --- a/package.nls.json +++ b/package.nls.json @@ -190,7 +190,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.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", diff --git a/src/view/treeNodes/commitNode.ts b/src/view/treeNodes/commitNode.ts index aca7201ae0..e84c7f7f1d 100644 --- a/src/view/treeNodes/commitNode.ts +++ b/src/view/treeNodes/commitNode.ts @@ -35,7 +35,6 @@ export class CommitNode extends TreeNode implements vscode.TreeItem { this.sha = commit.sha; this.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; this.contextValue = 'commit'; - this.description = this._getDescription(); } private _getDescription(): string | undefined { @@ -58,6 +57,7 @@ export class CommitNode extends TreeNode implements vscode.TreeItem { this.iconPath = (await DataUri.avatarCirclesAsImageDataUris(this.pullRequestManager.context, [author], 16, 16))[0]; } } + this.description = this._getDescription(); return this; } diff --git a/src/view/treeNodes/commitsCategoryNode.ts b/src/view/treeNodes/commitsCategoryNode.ts index 8151cecb64..43bbe9e2f2 100644 --- a/src/view/treeNodes/commitsCategoryNode.ts +++ b/src/view/treeNodes/commitsCategoryNode.ts @@ -45,7 +45,7 @@ export class CommitsNode extends TreeNode implements vscode.TreeItem { })); 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); + Logger.appendLine(`Commit SHA display setting has changed, refreshing Commits node`, PR_TREE); this.refresh(this); } })); From d21804c3b034dde52f6fd3fd5ef1c3fb001f5181 Mon Sep 17 00:00:00 2001 From: James Miller Date: Thu, 20 Aug 2026 14:41:56 +1000 Subject: [PATCH 3/3] Use this.sha instead of this.commit.sha in _getDescription --- src/view/treeNodes/commitNode.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view/treeNodes/commitNode.ts b/src/view/treeNodes/commitNode.ts index e84c7f7f1d..3ae3f92664 100644 --- a/src/view/treeNodes/commitNode.ts +++ b/src/view/treeNodes/commitNode.ts @@ -42,7 +42,7 @@ export class CommitNode extends TreeNode implements vscode.TreeItem { if (!vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get(SHOW_COMMIT_SHA_IN_TREE, false)) { return date; } - const shortSha = this.commit.sha.substring(0, 7); + const shortSha = this.sha.substring(0, 7); return date ? `${shortSha} · ${date}` : shortSha; }