@@ -50,10 +50,6 @@ export class GitBlame {
5050 return commit . hash === HASH_NO_COMMIT_GIT ;
5151 }
5252
53- public static isGeneratedCommit ( commit : IGitCommitInfo ) : boolean {
54- return commit . generated ;
55- }
56-
5753 public static internalHash ( hash : string ) : string {
5854 return hash . substr ( 0 , Property . get ( Properties . InternalHashLength ) ) ;
5955 }
@@ -71,7 +67,56 @@ export class GitBlame {
7167 this . init ( ) ;
7268 }
7369
74- public setupDisposables ( ) : void {
70+ public async blameLink ( ) : Promise < void > {
71+ const commitInfo = await this . getCommitInfo ( ) ;
72+ const commitToolUrl = this . getToolUrl ( commitInfo ) ;
73+
74+ if ( commitToolUrl ) {
75+ commands . executeCommand ( "vscode.open" , commitToolUrl ) ;
76+ } else {
77+ window . showErrorMessage (
78+ "Missing gitblame.commitUrl configuration value." ,
79+ ) ;
80+ }
81+ }
82+
83+ public async showMessage ( ) : Promise < void > {
84+ const commitInfo = await this . getCommitInfo ( ) ;
85+ const messageFormat = Property . get ( Properties . InfoMessageFormat ) ;
86+ const normalizedTokens = TextDecorator . normalizeCommitInfoTokens (
87+ commitInfo ,
88+ ) ;
89+ const message = TextDecorator . parseTokens (
90+ messageFormat ,
91+ normalizedTokens ,
92+ ) ;
93+ const extraActions = this . generateMessageActions ( commitInfo ) ;
94+
95+ this . updateView ( commitInfo ) ;
96+
97+ const actionedItem = await window . showInformationMessage (
98+ message ,
99+ ...( await extraActions ) ,
100+ ) ;
101+
102+ if ( actionedItem ) {
103+ actionedItem . takeAction ( ) ;
104+ }
105+ }
106+
107+ public defaultWebPath ( url : string , hash : string ) : string {
108+ return url . replace (
109+ / ^ ( g i t @ | h t t p s : \/ \/ ) ( [ ^ : \/ ] + ) [: \/ ] ( .* ) \. g i t $ / ,
110+ `https://$2/$3/commit/${ hash } ` ,
111+ ) ;
112+ }
113+
114+ public dispose ( ) : void {
115+ Disposable . from ( ...Object . values ( this . files ) ) . dispose ( ) ;
116+ this . disposable . dispose ( ) ;
117+ }
118+
119+ private setupDisposables ( ) : void {
75120 const disposables : Disposable [ ] = [ ] ;
76121
77122 // The blamer does not use the ErrorHandler but
@@ -87,7 +132,7 @@ export class GitBlame {
87132 ) ;
88133 }
89134
90- public setupListeners ( ) : void {
135+ private setupListeners ( ) : void {
91136 const disposables : Disposable [ ] = [ ] ;
92137
93138 window . onDidChangeActiveTextEditor (
@@ -109,16 +154,16 @@ export class GitBlame {
109154 this . disposable = Disposable . from ( this . disposable , ...disposables ) ;
110155 }
111156
112- public init ( ) : void {
157+ private init ( ) : void {
113158 this . onTextEditorMove ( ) ;
114159 }
115160
116- public async onTextEditorMove ( ) : Promise < void > {
161+ private async onTextEditorMove ( ) : Promise < void > {
117162 const beforeBlameOpenFile = this . getCurrentActiveFileName ( ) ;
118163 const beforeBlameLineNumber = this . getCurrentActiveLineNumber ( ) ;
119164 const commitInfo = await this . getCurrentLineInfo ( ) ;
120165
121- // Only update if we haven" t moved since we started blaming
166+ // Only update if we haven' t moved since we started blaming
122167 if (
123168 beforeBlameOpenFile === this . getCurrentActiveFileName ( ) &&
124169 beforeBlameLineNumber === this . getCurrentActiveLineNumber ( )
@@ -127,55 +172,6 @@ export class GitBlame {
127172 }
128173 }
129174
130- public async blameLink ( ) : Promise < void > {
131- const commitInfo = await this . getCommitInfo ( ) ;
132- const commitToolUrl = this . getToolUrl ( commitInfo ) ;
133-
134- if ( commitToolUrl ) {
135- commands . executeCommand ( "vscode.open" , commitToolUrl ) ;
136- } else {
137- window . showErrorMessage (
138- "Missing gitblame.commitUrl configuration value." ,
139- ) ;
140- }
141- }
142-
143- public async showMessage ( ) : Promise < void > {
144- const commitInfo = await this . getCommitInfo ( ) ;
145- const messageFormat = Property . get ( Properties . InfoMessageFormat ) ;
146- const normalizedTokens = TextDecorator . normalizeCommitInfoTokens (
147- commitInfo ,
148- ) ;
149- const message = TextDecorator . parseTokens (
150- messageFormat ,
151- normalizedTokens ,
152- ) ;
153- const extraActions = this . generateMessageActions ( commitInfo ) ;
154-
155- this . updateView ( commitInfo ) ;
156-
157- const actionedItem = await window . showInformationMessage (
158- message ,
159- ...( await extraActions ) ,
160- ) ;
161-
162- if ( actionedItem ) {
163- actionedItem . takeAction ( ) ;
164- }
165- }
166-
167- public defaultWebPath ( url : string , hash : string ) : string {
168- return url . replace (
169- / ^ ( g i t @ | h t t p s : \/ \/ ) ( [ ^ : \/ ] + ) [: \/ ] ( .* ) \. g i t $ / ,
170- `https://$2/$3/commit/${ hash } ` ,
171- ) ;
172- }
173-
174- public dispose ( ) : void {
175- Disposable . from ( ...Object . values ( this . files ) ) . dispose ( ) ;
176- this . disposable . dispose ( ) ;
177- }
178-
179175 private getCurrentActiveFileName ( ) : string {
180176 return (
181177 window . activeTextEditor && window . activeTextEditor . document . fileName
@@ -213,7 +209,7 @@ export class GitBlame {
213209 private async getCommitInfo ( ) : Promise < IGitCommitInfo > {
214210 const commitInfo = await this . getCurrentLineInfo ( ) ;
215211
216- if ( GitBlame . isGeneratedCommit ( commitInfo ) ) {
212+ if ( commitInfo . generated ) {
217213 window . showErrorMessage (
218214 "The current file and line can not be blamed." ,
219215 ) ;
@@ -244,7 +240,7 @@ export class GitBlame {
244240 }
245241
246242 private updateView ( commitInfo : IGitCommitInfo ) : void {
247- if ( GitBlame . isGeneratedCommit ( commitInfo ) ) {
243+ if ( commitInfo . generated ) {
248244 this . statusBarView . clear ( ) ;
249245 } else {
250246 this . statusBarView . update ( commitInfo ) ;
0 commit comments