Browse Source

Adds Open Changes submenu to Commit Graph rows

main
Eric Amodio 1 year ago
parent
commit
925199e785
3 changed files with 118 additions and 3 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +62
    -2
      package.json
  3. +55
    -1
      src/plus/webviews/graph/graphWebview.ts

+ 1
- 0
CHANGELOG.md View File

@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Column headers now show icons instead of text when their width is sufficiently small
- Adds _Share_, _Open Changes_, and _Open on Remote (Web)_ submenus to the new editor line numbers (gutter) context menu
- Adds an _Open Line Commit Details_ command to the _Open Changes_ submenus on editor context menus
- Adds an _Open Changes_ submenu to the row context menu on the _Commit Graph_
### Changed

+ 62
- 2
package.json View File

@ -7047,6 +7047,26 @@
"icon": "$(gitlens-compare-ref-working)"
},
{
"command": "gitlens.graph.openChangedFiles",
"title": "Open Files",
"category": "GitLens"
},
{
"command": "gitlens.graph.openChangedFileDiffs",
"title": "Open All Changes",
"category": "GitLens"
},
{
"command": "gitlens.graph.openChangedFileDiffsWithWorking",
"title": "Open All Changes with Working Tree",
"category": "GitLens"
},
{
"command": "gitlens.graph.openChangedFileRevisions",
"title": "Open Files at Revision",
"category": "GitLens"
},
{
"command": "gitlens.graph.addAuthor",
"title": "Add as Co-author",
"category": "GitLens",
@ -9226,6 +9246,22 @@
"when": "false"
},
{
"command": "gitlens.graph.openChangedFiles",
"when": "false"
},
{
"command": "gitlens.graph.openChangedFileDiffs",
"when": "false"
},
{
"command": "gitlens.graph.openChangedFileDiffsWithWorking",
"when": "false"
},
{
"command": "gitlens.graph.openChangedFileRevisions",
"when": "false"
},
{
"command": "gitlens.graph.addAuthor",
"when": "false"
},
@ -11921,6 +11957,11 @@
"group": "1_gitlens_actions_1@2"
},
{
"submenu": "gitlens/graph/commit/changes",
"when": "webviewItem =~ /gitlens:(commit|stash|wip)\\b/",
"group": "2_gitlens_quickopen@1"
},
{
"command": "gitlens.graph.showInDetailsView",
"when": "webviewItem =~ /gitlens:(commit|stash|wip)\\b/",
"group": "3_gitlens_explore@0"
@ -12301,6 +12342,25 @@
"group": "2_gitlens_quickopen_1@2"
}
],
"gitlens/graph/commit/changes": [
{
"command": "gitlens.graph.openChangedFileDiffs",
"group": "1_gitlens@1"
},
{
"command": "gitlens.graph.openChangedFileDiffsWithWorking",
"when": "webviewItem != gitlens:wip",
"group": "1_gitlens@2"
},
{
"command": "gitlens.graph.openChangedFiles",
"group": "2_gitlens@1"
},
{
"command": "gitlens.graph.openChangedFileRevisions",
"group": "2_gitlens@2"
}
],
"gitlens/commit/file/commit": [
{
"command": "gitlens.showInDetailsView",
@ -12901,8 +12961,8 @@
"label": "Open Changes"
},
{
"id": "gitlens/commit/file/copy",
"label": "Copy As"
"id": "gitlens/graph/commit/changes",
"label": "Open Changes"
},
{
"id": "gitlens/commit/file/commit",

+ 55
- 1
src/plus/webviews/graph/graphWebview.ts View File

@ -18,7 +18,13 @@ import type { Container } from '../../../container';
import type { CommitSelectedEvent } from '../../../eventBus';
import { PlusFeatures } from '../../../features';
import * as BranchActions from '../../../git/actions/branch';
import { showGraphDetailsView } from '../../../git/actions/commit';
import {
openAllChanges,
openAllChangesWithWorking,
openFiles,
openFilesAtRevision,
showGraphDetailsView,
} from '../../../git/actions/commit';
import * as ContributorActions from '../../../git/actions/contributor';
import * as RepoActions from '../../../git/actions/repository';
import * as StashActions from '../../../git/actions/stash';
@ -26,6 +32,7 @@ import * as TagActions from '../../../git/actions/tag';
import * as WorktreeActions from '../../../git/actions/worktree';
import { GitSearchError } from '../../../git/errors';
import { getBranchId, getBranchNameWithoutRemote, getRemoteNameFromBranchName } from '../../../git/models/branch';
import type { GitCommit } from '../../../git/models/commit';
import { uncommitted } from '../../../git/models/constants';
import { GitContributor } from '../../../git/models/contributor';
import type { GitGraph } from '../../../git/models/graph';
@ -396,6 +403,11 @@ export class GraphWebviewProvider implements WebviewProvider {
registerCommand('gitlens.graph.copyDeepLinkToCommit', this.copyDeepLinkToCommit, this),
registerCommand('gitlens.graph.copyDeepLinkToRepo', this.copyDeepLinkToRepo, this),
registerCommand('gitlens.graph.copyDeepLinkToTag', this.copyDeepLinkToTag, this),
registerCommand('gitlens.graph.openChangedFiles', this.openFiles, this),
registerCommand('gitlens.graph.openChangedFileDiffs', this.openAllChanges, this),
registerCommand('gitlens.graph.openChangedFileDiffsWithWorking', this.openAllChangesWithWorking, this),
registerCommand('gitlens.graph.openChangedFileRevisions', this.openRevisions, this),
];
}
@ -2447,6 +2459,38 @@ export class GraphWebviewProvider implements WebviewProvider {
}
@debug()
private async openFiles(item?: GraphItemContext) {
const commit = await this.getCommitFromGraphItemRef(item);
if (commit == null) return;
return openFiles(commit);
}
@debug()
private async openAllChanges(item?: GraphItemContext) {
const commit = await this.getCommitFromGraphItemRef(item);
if (commit == null) return;
return openAllChanges(commit);
}
@debug()
private async openAllChangesWithWorking(item?: GraphItemContext) {
const commit = await this.getCommitFromGraphItemRef(item);
if (commit == null) return;
return openAllChangesWithWorking(commit);
}
@debug()
private async openRevisions(item?: GraphItemContext) {
const commit = await this.getCommitFromGraphItemRef(item);
if (commit == null) return;
return openFilesAtRevision(commit);
}
@debug()
private addAuthor(item?: GraphItemContext) {
if (isGraphItemTypedContext(item, 'contributor')) {
const { repoPath, name, email, current } = item.webviewItemValue;
@ -2495,6 +2539,16 @@ export class GraphWebviewProvider implements WebviewProvider {
void this.notifyDidChangeColumns();
}
private getCommitFromGraphItemRef(item?: GraphItemContext): Promise<GitCommit | undefined> {
let ref: GitRevisionReference | GitStashReference | undefined = this.getGraphItemRef(item, 'revision');
if (ref != null) return this.container.git.getCommit(ref.repoPath, ref.ref);
ref = this.getGraphItemRef(item, 'stash');
if (ref != null) return this.container.git.getCommit(ref.repoPath, ref.ref);
return Promise.resolve(undefined);
}
private getGraphItemRef(item?: GraphItemContext | unknown | undefined): GitReference | undefined;
private getGraphItemRef(
item: GraphItemContext | unknown | undefined,

Loading…
Cancel
Save