@@ -7,6 +7,7 @@ import { GitUri } from '../git/gitUri';
7
7
import type { GitCommit , GitStashCommit } from '../git/models/commit' ;
8
8
import { isCommit } from '../git/models/commit' ;
9
9
import type { GitLog } from '../git/models/log' ;
10
+ import { createReference } from '../git/models/reference' ;
10
11
import {
11
12
showCommitNotFoundWarningMessage ,
12
13
showFileNotUnderSourceControlWarningMessage ,
@@ -33,25 +34,14 @@ export class ShowQuickCommitFileCommand extends ActiveEditorCachedCommand {
33
34
}
34
35
35
36
constructor ( private readonly container : Container ) {
36
- super ( [
37
- Commands . ShowQuickCommitFile ,
38
- Commands . ShowQuickCommitRevision ,
39
- Commands . ShowQuickCommitRevisionInDiffLeft ,
40
- Commands . ShowQuickCommitRevisionInDiffRight ,
41
- ] ) ;
37
+ super ( Commands . ShowQuickCommitFile ) ;
42
38
}
43
39
44
40
protected override async preExecute ( context : CommandContext , args ?: ShowQuickCommitFileCommandArgs ) {
45
41
if ( context . type === 'editorLine' ) {
46
42
args = { ...args , line : context . line } ;
47
43
}
48
44
49
- if ( context . editor != null && context . command . startsWith ( Commands . ShowQuickCommitRevision ) ) {
50
- const gitUri = await GitUri . fromUri ( context . editor . document . uri ) ;
51
-
52
- args = { ...args , sha : gitUri . sha } ;
53
- }
54
-
55
45
if ( context . type === 'viewItem' ) {
56
46
args = { ...args , sha : context . node . uri . sha } ;
57
47
@@ -157,3 +147,36 @@ export class ShowQuickCommitFileCommand extends ActiveEditorCachedCommand {
157
147
}
158
148
}
159
149
}
150
+
151
+ @command ( )
152
+ export class ShowQuickCommitRevisionCommand extends ActiveEditorCachedCommand {
153
+ constructor ( private readonly container : Container ) {
154
+ super ( [
155
+ Commands . ShowQuickCommitRevision ,
156
+ Commands . ShowQuickCommitRevisionInDiffLeft ,
157
+ Commands . ShowQuickCommitRevisionInDiffRight ,
158
+ ] ) ;
159
+ }
160
+
161
+ async execute ( editor ?: TextEditor , uri ?: Uri ) {
162
+ uri = getCommandUri ( uri , editor ) ;
163
+ if ( uri == null ) return ;
164
+
165
+ try {
166
+ const gitUri = await GitUri . fromUri ( uri ) ;
167
+ if ( gitUri ?. sha == null ) return ;
168
+
169
+ await executeGitCommand ( {
170
+ command : 'show' ,
171
+ state : {
172
+ repo : gitUri . repoPath ,
173
+ reference : createReference ( gitUri . sha , gitUri . repoPath ! , { refType : 'revision' } ) ,
174
+ fileName : gitUri . fsPath ,
175
+ } ,
176
+ } ) ;
177
+ } catch ( ex ) {
178
+ Logger . error ( ex , 'ShowQuickCommitRevisionCommand' ) ;
179
+ void showGenericErrorMessage ( 'Unable to show commit details' ) ;
180
+ }
181
+ }
182
+ }
0 commit comments