Skip to content

Commit 9a85f21

Browse files
committed
Aligns commands between quickpicks and view
1 parent b5640fd commit 9a85f21

File tree

3 files changed

+102
-90
lines changed

3 files changed

+102
-90
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1111

1212
### Changed
1313
- Overhauls the internal way GitLens deals with Uris and revisions should be far more robust and lead to many fewer edge-case issues
14+
- Aligns quick pick menu commands more with the `GitLens` view context menus
1415

1516
### Fixed
1617
- Fixes [#220](https://github.com/eamodio/vscode-gitlens/issues/220) - Open Revision quick pick results in empty file

src/quickPicks/commitDetails.ts

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class OpenCommitFilesCommandQuickPickItem extends OpenFilesCommandQuickPi
6262
f => GitUri.fromFileStatus(f, repoPath));
6363

6464
super(uris, item || {
65-
label: `$(file-symlink-file) Open Changed Files`,
65+
label: `$(file-symlink-file) Open Files`,
6666
description: ''
6767
// detail: `Opens all of the changed file in the working tree`
6868
});
@@ -79,7 +79,7 @@ export class OpenCommitFileRevisionsCommandQuickPickItem extends OpenFilesComman
7979
f => GitUri.toRevisionUri(f.status === 'D' ? commit.previousFileSha : commit.sha, f, commit.repoPath));
8080

8181
super(uris, item || {
82-
label: `$(file-symlink-file) Open Changed Revisions`,
82+
label: `$(file-symlink-file) Open Revisions`,
8383
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} in ${GlyphChars.Space}$(git-commit) ${commit.shortSha}`
8484
// detail: `Opens all of the changed files in $(git-commit) ${commit.shortSha}`
8585
});
@@ -108,7 +108,8 @@ export class CommitDetailsQuickPick {
108108
stashItem: commit as GitStashCommit,
109109
goBackCommand: currentCommand
110110
} as StashApplyCommandArgs
111-
]));
111+
])
112+
);
112113

113114
items.splice(index++, 0, new CommandQuickPickItem({
114115
label: `$(x) Delete Stashed Changes`,
@@ -119,8 +120,44 @@ export class CommitDetailsQuickPick {
119120
stashItem: commit as GitStashCommit,
120121
goBackCommand: currentCommand
121122
} as StashDeleteCommandArgs
122-
]));
123+
])
124+
);
123125
}
126+
else {
127+
const remotes = (await git.getRemotes(commit.repoPath)).filter(r => r.provider !== undefined);
128+
if (remotes.length) {
129+
items.splice(index++, 0, new OpenRemotesCommandQuickPickItem(remotes, {
130+
type: 'commit',
131+
sha: commit.sha
132+
} as RemoteResource, currentCommand));
133+
}
134+
}
135+
136+
items.splice(index++, 0, new OpenCommitFilesCommandQuickPickItem(commit));
137+
items.splice(index++, 0, new OpenCommitFileRevisionsCommandQuickPickItem(commit));
138+
139+
items.splice(index++, 0, new CommandQuickPickItem({
140+
label: `$(git-compare) Compare Directory with Previous Revision`,
141+
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(git-commit) ${commit.previousFileShortSha} ${GlyphChars.Space} $(git-compare) ${GlyphChars.Space} $(git-commit) ${commit.shortSha}`
142+
}, Commands.DiffDirectory, [
143+
commit.uri,
144+
{
145+
shaOrBranch1: commit.previousFileSha,
146+
shaOrBranch2: commit.sha
147+
} as DiffDirectoryCommandCommandArgs
148+
])
149+
);
150+
151+
items.splice(index++, 0, new CommandQuickPickItem({
152+
label: `$(git-compare) Compare Directory with Working Tree`,
153+
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(git-commit) ${commit.shortSha} ${GlyphChars.Space} $(git-compare) ${GlyphChars.Space} $(file-directory) Working Tree`
154+
}, Commands.DiffDirectory, [
155+
uri,
156+
{
157+
shaOrBranch1: commit.sha
158+
} as DiffDirectoryCommandCommandArgs
159+
])
160+
);
124161

125162
if (!stash) {
126163
items.splice(index++, 0, new CommandQuickPickItem({
@@ -131,50 +168,21 @@ export class CommitDetailsQuickPick {
131168
{
132169
sha: commit.sha
133170
} as CopyShaToClipboardCommandArgs
134-
]));
171+
])
172+
);
135173
}
136174

137175
items.splice(index++, 0, new CommandQuickPickItem({
138-
label: `$(clippy) Copy Message to Clipboard`,
176+
label: `$(clippy) Copy Commit Message to Clipboard`,
139177
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${commit.message}`
140178
}, Commands.CopyMessageToClipboard, [
141179
uri,
142180
{
143181
message: commit.message,
144182
sha: commit.sha
145183
} as CopyMessageToClipboardCommandArgs
146-
]));
147-
148-
if (!stash) {
149-
const remotes = (await git.getRemotes(commit.repoPath)).filter(r => r.provider !== undefined);
150-
if (remotes.length) {
151-
items.splice(index++, 0, new OpenRemotesCommandQuickPickItem(remotes, {
152-
type: 'commit',
153-
sha: commit.sha
154-
} as RemoteResource, currentCommand));
155-
}
156-
157-
items.splice(index++, 0, new CommandQuickPickItem({
158-
label: `$(git-compare) Compare Directory with Previous Commit`,
159-
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(git-commit) ${commit.previousFileShortSha} ${GlyphChars.Space} $(git-compare) ${GlyphChars.Space} $(git-commit) ${commit.shortSha}`
160-
}, Commands.DiffDirectory, [
161-
commit.uri,
162-
{
163-
shaOrBranch1: commit.previousFileSha,
164-
shaOrBranch2: commit.sha
165-
} as DiffDirectoryCommandCommandArgs
166-
]));
167-
}
168-
169-
items.splice(index++, 0, new CommandQuickPickItem({
170-
label: `$(git-compare) Compare Directory with Working Tree`,
171-
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(git-commit) ${commit.shortSha} ${GlyphChars.Space} $(git-compare) ${GlyphChars.Space} $(file-directory) Working Tree`
172-
}, Commands.DiffDirectory, [
173-
uri,
174-
{
175-
shaOrBranch1: commit.sha
176-
} as DiffDirectoryCommandCommandArgs
177-
]));
184+
])
185+
);
178186

179187
items.splice(index++, 0, new CommandQuickPickItem({
180188
label: `Changed Files`,
@@ -187,10 +195,8 @@ export class CommitDetailsQuickPick {
187195
sha: commit.sha,
188196
goBackCommand
189197
} as ShowQuickCommitDetailsCommandArgs
190-
]));
191-
192-
items.push(new OpenCommitFilesCommandQuickPickItem(commit));
193-
items.push(new OpenCommitFileRevisionsCommandQuickPickItem(commit));
198+
])
199+
);
194200

195201
if (goBackCommand) {
196202
items.splice(0, 0, goBackCommand);

src/quickPicks/commitFileDetails.ts

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -66,65 +66,30 @@ export class CommitFileDetailsQuickPick {
6666

6767
await commit.resolvePreviousFileSha(git);
6868

69-
if (!stash) {
69+
if (commit.previousFileShortSha) {
7070
items.push(new CommandQuickPickItem({
71-
label: `$(git-commit) Show Commit Details`,
72-
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(git-commit) ${commit.shortSha}`
73-
}, Commands.ShowQuickCommitDetails, [
74-
commit.toGitUri(),
71+
label: `$(git-compare) Open Changes`,
72+
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(git-commit) ${commit.previousFileShortSha} ${GlyphChars.Space} $(git-compare) ${GlyphChars.Space} $(git-commit) ${commit.shortSha}`
73+
}, Commands.DiffWithPrevious, [
74+
commit.uri,
7575
{
76-
commit,
77-
sha: commit.sha,
78-
goBackCommand: currentCommand
79-
} as ShowQuickCommitDetailsCommandArgs
80-
]));
81-
82-
if (commit.previousFileShortSha) {
83-
items.push(new CommandQuickPickItem({
84-
label: `$(git-compare) Compare File with Previous Revision`,
85-
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(git-commit) ${commit.previousFileShortSha} ${GlyphChars.Space} $(git-compare) ${GlyphChars.Space} $(git-commit) ${commit.shortSha}`
86-
}, Commands.DiffWithPrevious, [
87-
commit.uri,
88-
{
89-
commit
90-
} as DiffWithPreviousCommandArgs
91-
]));
92-
}
76+
commit
77+
} as DiffWithPreviousCommandArgs
78+
])
79+
);
9380
}
9481

9582
if (commit.workingFileName) {
9683
items.push(new CommandQuickPickItem({
97-
label: `$(git-compare) Compare File with Working Revision`,
84+
label: `$(git-compare) Open Changes with Working Tree`,
9885
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(git-commit) ${commit.shortSha} ${GlyphChars.Space} $(git-compare) ${GlyphChars.Space} $(file-text) ${workingName}`
9986
}, Commands.DiffWithWorking, [
10087
Uri.file(path.resolve(commit.repoPath, commit.workingFileName)),
10188
{
10289
commit
10390
} as DiffWithWorkingCommandArgs
104-
]));
105-
}
106-
107-
if (!stash) {
108-
items.push(new CommandQuickPickItem({
109-
label: `$(clippy) Copy Commit ID to Clipboard`,
110-
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${commit.shortSha}`
111-
}, Commands.CopyShaToClipboard, [
112-
uri,
113-
{
114-
sha: commit.sha
115-
} as CopyShaToClipboardCommandArgs
116-
]));
117-
118-
items.push(new CommandQuickPickItem({
119-
label: `$(clippy) Copy Message to Clipboard`,
120-
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${commit.message}`
121-
}, Commands.CopyMessageToClipboard, [
122-
uri,
123-
{
124-
message: commit.message,
125-
sha: commit.sha
126-
} as CopyMessageToClipboardCommandArgs
127-
]));
91+
])
92+
);
12893
}
12994

13095
if (commit.workingFileName && commit.status !== 'D') {
@@ -142,6 +107,7 @@ export class CommitFileDetailsQuickPick {
142107
branch: branch!.name
143108
} as RemoteResource, currentCommand));
144109
}
110+
145111
if (!stash) {
146112
items.push(new OpenRemotesCommandQuickPickItem(remotes, {
147113
type: 'revision',
@@ -151,6 +117,45 @@ export class CommitFileDetailsQuickPick {
151117
}
152118
}
153119

120+
if (!stash) {
121+
items.push(new CommandQuickPickItem({
122+
label: `$(clippy) Copy Commit ID to Clipboard`,
123+
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${commit.shortSha}`
124+
}, Commands.CopyShaToClipboard, [
125+
uri,
126+
{
127+
sha: commit.sha
128+
} as CopyShaToClipboardCommandArgs
129+
])
130+
);
131+
132+
items.push(new CommandQuickPickItem({
133+
label: `$(clippy) Copy Commit Message to Clipboard`,
134+
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${commit.message}`
135+
}, Commands.CopyMessageToClipboard, [
136+
uri,
137+
{
138+
message: commit.message,
139+
sha: commit.sha
140+
} as CopyMessageToClipboardCommandArgs
141+
]));
142+
}
143+
144+
if (!stash) {
145+
items.push(new CommandQuickPickItem({
146+
label: `$(git-commit) Show Commit Details`,
147+
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(git-commit) ${commit.shortSha}`
148+
}, Commands.ShowQuickCommitDetails, [
149+
commit.toGitUri(),
150+
{
151+
commit,
152+
sha: commit.sha,
153+
goBackCommand: currentCommand
154+
} as ShowQuickCommitDetailsCommandArgs
155+
])
156+
);
157+
}
158+
154159
if (commit.workingFileName) {
155160
items.push(new CommandQuickPickItem({
156161
label: `$(history) Show File History`,
@@ -282,7 +287,7 @@ export class CommitFileDetailsQuickPick {
282287

283288
const pick = await window.showQuickPick(items, {
284289
matchOnDescription: true,
285-
placeHolder: `${commit.getFormattedPath()} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${isUncommitted ? `Uncommitted ${GlyphChars.ArrowRightHollow} ` : '' }${commit.shortSha} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${commit.author}, ${commit.fromNow()} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${commit.message}`,
290+
placeHolder: `${commit.getFormattedPath()} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${isUncommitted ? `Uncommitted ${GlyphChars.ArrowRightHollow} ` : ''}${commit.shortSha} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${commit.author}, ${commit.fromNow()} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${commit.message}`,
286291
ignoreFocusOut: getQuickPickIgnoreFocusOut(),
287292
onDidSelectItem: (item: QuickPickItem) => {
288293
scope.setKeyCommand('right', item as KeyCommand);

0 commit comments

Comments
 (0)