@@ -27,10 +27,10 @@ class TextDocumentContentProvider implements vscode.TextDocumentContentProvider
27
27
public async provideTextDocumentContent ( uri : vscode . Uri , token : vscode . CancellationToken ) : Promise < string > {
28
28
try {
29
29
let branchName = this . getBranchFromURI ( uri ) ;
30
- if ( this . html . hasOwnProperty ( branchName ) ) {
30
+ if ( this . html . hasOwnProperty ( branchName ) ) {
31
31
return this . html [ branchName ] ;
32
32
}
33
- const entries = await gitHistory . getLogEntries ( gitRepoPath , pageIndex , pageSize ) ;
33
+ const entries = await gitHistory . getLogEntries ( gitRepoPath , branchName , pageIndex , pageSize ) ;
34
34
canGoPrevious = pageIndex > 0 ;
35
35
canGoNext = entries . length === pageSize ;
36
36
this . entries = entries ;
@@ -53,14 +53,18 @@ class TextDocumentContentProvider implements vscode.TextDocumentContentProvider
53
53
}
54
54
55
55
private clearCache ( name : string ) {
56
- if ( this . html . hasOwnProperty ( name ) ) {
56
+ if ( this . html . hasOwnProperty ( name ) ) {
57
57
delete this . html [ name ] ;
58
58
}
59
59
}
60
60
61
61
private getBranchFromURI ( uri : vscode . Uri ) : string {
62
- let re = uri . query . match ( / b r a n c h = ( [ a - z 0 - 9 _ \- . ] + ) / i) ;
63
- return ( re ) ? re [ 1 ] : 'master' ;
62
+ if ( uri . query . length > 0 ) {
63
+ let re = uri . query . match ( / b r a n c h = ( [ a - z 0 - 9 _ \- . ] + ) / i) ;
64
+ return ( re ) ? re [ 1 ] : 'master' ;
65
+ } else {
66
+ return '' ;
67
+ }
64
68
}
65
69
66
70
private getStyleSheetPath ( resourceName : string ) : string {
@@ -115,6 +119,16 @@ export function activate(context: vscode.ExtensionContext) {
115
119
let registration = vscode . workspace . registerTextDocumentContentProvider ( gitHistorySchema , provider ) ;
116
120
117
121
let disposable = vscode . commands . registerCommand ( 'git.viewHistory' , async ( fileUri ?: vscode . Uri ) => {
122
+ const itemPickList : vscode . QuickPickItem [ ] = [ ] ;
123
+ itemPickList . push ( { label : 'Current branch' , description : '' } ) ;
124
+ itemPickList . push ( { label : 'All branches' , description : '' } ) ;
125
+ let modeChoice = await vscode . window . showQuickPick ( itemPickList , { placeHolder : 'Show history for...' , matchOnDescription : true } ) ;
126
+
127
+ let title : string ;
128
+ if ( modeChoice === undefined ) {
129
+ return ;
130
+ }
131
+
118
132
let fileName = '' ;
119
133
let branchName = 'master' ;
120
134
@@ -138,8 +152,16 @@ export function activate(context: vscode.ExtensionContext) {
138
152
pageIndex = 0 ;
139
153
canGoPrevious = false ;
140
154
canGoNext = true ;
141
- previewUri = vscode . Uri . parse ( gitHistorySchema + '://authority/git-history?branch=' + encodeURI ( branchName ) ) ;
142
- return vscode . commands . executeCommand ( 'vscode.previewHtml' , previewUri , vscode . ViewColumn . One , 'Git History (' + branchName + ')' ) . then ( ( success ) => {
155
+
156
+ if ( modeChoice . label === 'All branches' ) {
157
+ previewUri = vscode . Uri . parse ( gitHistorySchema + '://authority/git-history' ) ;
158
+ title = 'Git History (all branches)' ;
159
+ }
160
+ else {
161
+ previewUri = vscode . Uri . parse ( gitHistorySchema + '://authority/git-history?branch=' + encodeURI ( branchName ) ) ;
162
+ title = 'Git History (' + branchName + ')' ;
163
+ }
164
+ return vscode . commands . executeCommand ( 'vscode.previewHtml' , previewUri , vscode . ViewColumn . One , title ) . then ( ( success ) => {
143
165
provider . update ( previewUri ) ;
144
166
} , ( reason ) => {
145
167
vscode . window . showErrorMessage ( reason ) ;
0 commit comments