Browse Source

Adds show in commit graph to commit quick picks

main
Eric Amodio 2 years ago
parent
commit
5f42ce3f75
4 changed files with 26 additions and 1 deletions
  1. +1
    -1
      CHANGELOG.md
  2. +12
    -0
      src/commands/gitCommands.actions.ts
  3. +3
    -0
      src/commands/quickCommand.steps.ts
  4. +10
    -0
      src/quickpicks/items/commits.ts

+ 1
- 1
CHANGELOG.md View File

@ -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

+ 12
- 0
src/commands/gitCommands.actions.ts View File

@ -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<void> {
return Container.instance.commitDetailsView.show({ ...options, commit: commit });
}
export async function showInCommitGraph(
commit: GitRevisionReference | GitCommit,
options?: { preserveFocus?: boolean },
): Promise<void> {
void (await executeCommand<ShowCommitInGraphCommandArgs>(Commands.ShowCommitInGraph, {
sha: commit.ref,
repoPath: commit.repoPath,
preserveFocus: options?.preserveFocus,
}));
}
}
export namespace Contributor {

+ 3
- 0
src/commands/quickCommand.steps.ts View File

@ -40,6 +40,7 @@ import {
CommitOpenDirectoryCompareWithWorkingCommandQuickPickItem,
CommitOpenFileCommandQuickPickItem,
CommitOpenFilesCommandQuickPickItem,
CommitOpenInGraphCommandQuickPickItem,
CommitOpenRevisionCommandQuickPickItem,
CommitOpenRevisionsCommandQuickPickItem,
CommitRestoreFileChangesCommandQuickPickItem,
@ -1561,6 +1562,7 @@ async function getShowCommitOrStashStepItems<
>(state: State): Promise<CommandQuickPickItem[]> {
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)) {

+ 10
- 0
src/quickpicks/items/commits.ts View File

@ -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<void> {
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');

Loading…
Cancel
Save