diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f8b83c..9fa58e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Added -- Adds a `Show in Commit Graph` action to the hovers +- Adds a `Show in Commit Graph` action to the hovers and commit quick pick menus ### Changed diff --git a/src/commands/gitCommands.actions.ts b/src/commands/gitCommands.actions.ts index a20ff87..54e3c87 100644 --- a/src/commands/gitCommands.actions.ts +++ b/src/commands/gitCommands.actions.ts @@ -29,6 +29,7 @@ import { GitRevision } from '../git/models/reference'; import type { GitRemote } from '../git/models/remote'; import type { Repository } from '../git/models/repository'; import type { GitWorktree } from '../git/models/worktree'; +import type { ShowCommitInGraphCommandArgs } from '../plus/webviews/graph/graphWebview'; import { RepositoryPicker } from '../quickpicks/repositoryPicker'; import { ensure } from '../system/array'; import { executeCommand, executeCoreCommand, executeEditorCommand } from '../system/command'; @@ -763,6 +764,17 @@ export namespace GitActions { ): Promise { return Container.instance.commitDetailsView.show({ ...options, commit: commit }); } + + export async function showInCommitGraph( + commit: GitRevisionReference | GitCommit, + options?: { preserveFocus?: boolean }, + ): Promise { + void (await executeCommand(Commands.ShowCommitInGraph, { + sha: commit.ref, + repoPath: commit.repoPath, + preserveFocus: options?.preserveFocus, + })); + } } export namespace Contributor { diff --git a/src/commands/quickCommand.steps.ts b/src/commands/quickCommand.steps.ts index 6067033..085d420 100644 --- a/src/commands/quickCommand.steps.ts +++ b/src/commands/quickCommand.steps.ts @@ -40,6 +40,7 @@ import { CommitOpenDirectoryCompareWithWorkingCommandQuickPickItem, CommitOpenFileCommandQuickPickItem, CommitOpenFilesCommandQuickPickItem, + CommitOpenInGraphCommandQuickPickItem, CommitOpenRevisionCommandQuickPickItem, CommitOpenRevisionsCommandQuickPickItem, CommitRestoreFileChangesCommandQuickPickItem, @@ -1561,6 +1562,7 @@ async function getShowCommitOrStashStepItems< >(state: State): Promise { const items: (CommandQuickPickItem | QuickPickSeparator)[] = [ new CommitOpenDetailsCommandQuickPickItem(state.reference), + new CommitOpenInGraphCommandQuickPickItem(state.reference), ]; let unpublished: boolean | undefined; @@ -1912,6 +1914,7 @@ async function getShowCommitOrStashFileStepItems< const items: (CommandQuickPickItem | QuickPickSeparator)[] = [ new CommitOpenDetailsCommandQuickPickItem(state.reference), + new CommitOpenInGraphCommandQuickPickItem(state.reference), ]; if (isStash(state.reference)) { diff --git a/src/quickpicks/items/commits.ts b/src/quickpicks/items/commits.ts index 4d271f6..68ca6c1 100644 --- a/src/quickpicks/items/commits.ts +++ b/src/quickpicks/items/commits.ts @@ -263,6 +263,16 @@ export class CommitOpenDetailsCommandQuickPickItem extends CommandQuickPickItem } } +export class CommitOpenInGraphCommandQuickPickItem extends CommandQuickPickItem { + constructor(private readonly commit: GitCommit, item?: QuickPickItem) { + super(item ?? '$(gitlens-graph) Show in Commit Graph'); + } + + override execute(options: { preserveFocus?: boolean; preview?: boolean }): Promise { + return GitActions.Commit.showInCommitGraph(this.commit, { preserveFocus: options?.preserveFocus }); + } +} + export class CommitOpenFilesCommandQuickPickItem extends CommandQuickPickItem { constructor(private readonly commit: GitCommit, item?: QuickPickItem) { super(item ?? '$(files) Open Files');