@@ -7,7 +7,7 @@ import { AskpassEnvironment, AskpassManager } from './askpass/askpassManager';
7
7
import { getConfig } from './config' ;
8
8
import { Logger } from './logger' ;
9
9
import { CommitOrdering , DateType , DeepWriteable , ErrorInfo , GitCommit , GitCommitDetails , GitCommitStash , GitConfigLocation , GitFileChange , GitFileStatus , GitPushBranchMode , GitRepoConfig , GitRepoConfigBranches , GitResetMode , GitSignature , GitSignatureStatus , GitStash , GitTagDetails , MergeActionOn , RebaseActionOn , SquashMessageFormat , TagType , Writeable } from './types' ;
10
- import { GitExecutable , UNABLE_TO_FIND_GIT_MSG , UNCOMMITTED , abbrevCommit , constructIncompatibleGitVersionMessage , doesVersionMeetRequirement , getPathFromStr , getPathFromUri , openGitTerminal , pathWithTrailingSlash , realpath , resolveSpawnOutput , showErrorMessage } from './utils' ;
10
+ import { GitExecutable , GitVersionRequirement , UNABLE_TO_FIND_GIT_MSG , UNCOMMITTED , abbrevCommit , constructIncompatibleGitVersionMessage , doesVersionMeetRequirement , getPathFromStr , getPathFromUri , openGitTerminal , pathWithTrailingSlash , realpath , resolveSpawnOutput , showErrorMessage } from './utils' ;
11
11
import { Disposable } from './utils/disposable' ;
12
12
import { Event } from './utils/event' ;
13
13
@@ -17,21 +17,15 @@ const INVALID_BRANCH_REGEXP = /^\(.* .*\)$/;
17
17
const REMOTE_HEAD_BRANCH_REGEXP = / ^ r e m o t e s \/ .* \/ H E A D $ / ;
18
18
const GIT_LOG_SEPARATOR = 'XX7Nal-YARtTpjCikii9nJxER19D6diSyk-AWkPb' ;
19
19
20
- export const GIT_CONFIG = {
21
- DIFF : {
22
- GUI_TOOL : 'diff.guitool' ,
23
- TOOL : 'diff.tool'
24
- } ,
25
- REMOTE : {
26
- PUSH_DEFAULT : 'remote.pushdefault'
27
- } ,
28
- USER : {
29
- EMAIL : 'user.email' ,
30
- NAME : 'user.name'
31
- }
32
- } ;
20
+ export const enum GitConfigKey {
21
+ DiffGuiTool = 'diff.guitool' ,
22
+ DiffTool = 'diff.tool' ,
23
+ RemotePushDefault = 'remote.pushdefault' ,
24
+ UserEmail = 'user.email' ,
25
+ UserName = 'user.name'
26
+ }
33
27
34
- const GPG_STATUS_CODE_PARSING_DETAILS : { [ statusCode : string ] : GpgStatusCodeParsingDetails } = {
28
+ const GPG_STATUS_CODE_PARSING_DETAILS : Readonly < { [ statusCode : string ] : GpgStatusCodeParsingDetails } > = {
35
29
'GOODSIG' : { status : GitSignatureStatus . GoodAndValid , uid : true } ,
36
30
'BADSIG' : { status : GitSignatureStatus . Bad , uid : true } ,
37
31
'ERRSIG' : { status : GitSignatureStatus . CannotBeChecked , uid : false } ,
@@ -95,9 +89,9 @@ export class DataSource extends Disposable {
95
89
* Set the Git executable used by the DataSource.
96
90
* @param gitExecutable The Git executable.
97
91
*/
98
- public setGitExecutable ( gitExecutable : GitExecutable | null ) {
92
+ private setGitExecutable ( gitExecutable : GitExecutable | null ) {
99
93
this . gitExecutable = gitExecutable ;
100
- this . gitExecutableSupportsGpgInfo = gitExecutable !== null ? doesVersionMeetRequirement ( gitExecutable . version , '2.4.0' ) : false ;
94
+ this . gitExecutableSupportsGpgInfo = gitExecutable !== null && doesVersionMeetRequirement ( gitExecutable . version , GitVersionRequirement . GpgInfo ) ;
101
95
this . generateGitCommandFormats ( ) ;
102
96
}
103
97
@@ -314,22 +308,22 @@ export class DataSource extends Disposable {
314
308
return {
315
309
config : {
316
310
branches : branches ,
317
- diffTool : getConfigValue ( consolidatedConfigs , GIT_CONFIG . DIFF . TOOL ) ,
318
- guiDiffTool : getConfigValue ( consolidatedConfigs , GIT_CONFIG . DIFF . GUI_TOOL ) ,
319
- pushDefault : getConfigValue ( consolidatedConfigs , GIT_CONFIG . REMOTE . PUSH_DEFAULT ) ,
311
+ diffTool : getConfigValue ( consolidatedConfigs , GitConfigKey . DiffTool ) ,
312
+ guiDiffTool : getConfigValue ( consolidatedConfigs , GitConfigKey . DiffGuiTool ) ,
313
+ pushDefault : getConfigValue ( consolidatedConfigs , GitConfigKey . RemotePushDefault ) ,
320
314
remotes : remotes . map ( ( remote ) => ( {
321
315
name : remote ,
322
316
url : getConfigValue ( localConfigs , 'remote.' + remote + '.url' ) ,
323
317
pushUrl : getConfigValue ( localConfigs , 'remote.' + remote + '.pushurl' )
324
318
} ) ) ,
325
319
user : {
326
320
name : {
327
- local : getConfigValue ( localConfigs , GIT_CONFIG . USER . NAME ) ,
328
- global : getConfigValue ( globalConfigs , GIT_CONFIG . USER . NAME )
321
+ local : getConfigValue ( localConfigs , GitConfigKey . UserName ) ,
322
+ global : getConfigValue ( globalConfigs , GitConfigKey . UserName )
329
323
} ,
330
324
email : {
331
- local : getConfigValue ( localConfigs , GIT_CONFIG . USER . EMAIL ) ,
332
- global : getConfigValue ( globalConfigs , GIT_CONFIG . USER . EMAIL )
325
+ local : getConfigValue ( localConfigs , GitConfigKey . UserEmail ) ,
326
+ global : getConfigValue ( globalConfigs , GitConfigKey . UserEmail )
333
327
}
334
328
}
335
329
} ,
@@ -503,8 +497,8 @@ export class DataSource extends Disposable {
503
497
* @returns The tag details.
504
498
*/
505
499
public getTagDetails ( repo : string , tagName : string ) : Promise < GitTagDetailsData > {
506
- if ( this . gitExecutable !== null && ! doesVersionMeetRequirement ( this . gitExecutable . version , '1.7.8' ) ) {
507
- return Promise . resolve ( { details : null , error : constructIncompatibleGitVersionMessage ( this . gitExecutable , '1.7.8' , 'retrieving Tag Details' ) } ) ;
500
+ if ( this . gitExecutable !== null && ! doesVersionMeetRequirement ( this . gitExecutable . version , GitVersionRequirement . TagDetails ) ) {
501
+ return Promise . resolve ( { details : null , error : constructIncompatibleGitVersionMessage ( this . gitExecutable , GitVersionRequirement . TagDetails , 'retrieving Tag Details' ) } ) ;
508
502
}
509
503
510
504
const ref = 'refs/tags/' + tagName ;
@@ -758,8 +752,8 @@ export class DataSource extends Disposable {
758
752
if ( pruneTags ) {
759
753
if ( ! prune ) {
760
754
return Promise . resolve ( 'In order to Prune Tags, pruning must also be enabled when fetching from ' + ( remote !== null ? 'a remote' : 'remote(s)' ) + '.' ) ;
761
- } else if ( this . gitExecutable !== null && ! doesVersionMeetRequirement ( this . gitExecutable . version , '2.17.0' ) ) {
762
- return Promise . resolve ( constructIncompatibleGitVersionMessage ( this . gitExecutable , '2.17.0' , 'pruning tags when fetching' ) ) ;
755
+ } else if ( this . gitExecutable !== null && ! doesVersionMeetRequirement ( this . gitExecutable . version , GitVersionRequirement . FetchAndPruneTags ) ) {
756
+ return Promise . resolve ( constructIncompatibleGitVersionMessage ( this . gitExecutable , GitVersionRequirement . FetchAndPruneTags , 'pruning tags when fetching' ) ) ;
763
757
}
764
758
args . push ( '--prune-tags' ) ;
765
759
}
@@ -1139,23 +1133,23 @@ export class DataSource extends Disposable {
1139
1133
/**
1140
1134
* Set a configuration value for a repository.
1141
1135
* @param repo The path of the repository.
1142
- * @param key The key to be set.
1136
+ * @param key The Git Config Key to be set.
1143
1137
* @param value The value to be set.
1144
1138
* @param location The location where the configuration value should be set.
1145
1139
* @returns The ErrorInfo from the executed command.
1146
1140
*/
1147
- public setConfigValue ( repo : string , key : string , value : string , location : GitConfigLocation ) {
1141
+ public setConfigValue ( repo : string , key : GitConfigKey , value : string , location : GitConfigLocation ) {
1148
1142
return this . runGitCommand ( [ 'config' , '--' + location , key , value ] , repo ) ;
1149
1143
}
1150
1144
1151
1145
/**
1152
1146
* Unset a configuration value for a repository.
1153
1147
* @param repo The path of the repository.
1154
- * @param key The key to be unset.
1148
+ * @param key The Git Config Key to be unset.
1155
1149
* @param location The location where the configuration value should be unset.
1156
1150
* @returns The ErrorInfo from the executed command.
1157
1151
*/
1158
- public unsetConfigValue ( repo : string , key : string , location : GitConfigLocation ) {
1152
+ public unsetConfigValue ( repo : string , key : GitConfigKey , location : GitConfigLocation ) {
1159
1153
return this . runGitCommand ( [ 'config' , '--' + location , '--unset-all' , key ] , repo ) ;
1160
1154
}
1161
1155
@@ -1236,8 +1230,8 @@ export class DataSource extends Disposable {
1236
1230
public pushStash ( repo : string , message : string , includeUntracked : boolean ) : Promise < ErrorInfo > {
1237
1231
if ( this . gitExecutable === null ) {
1238
1232
return Promise . resolve ( UNABLE_TO_FIND_GIT_MSG ) ;
1239
- } else if ( ! doesVersionMeetRequirement ( this . gitExecutable . version , '2.13.2' ) ) {
1240
- return Promise . resolve ( constructIncompatibleGitVersionMessage ( this . gitExecutable , '2.13.2' ) ) ;
1233
+ } else if ( ! doesVersionMeetRequirement ( this . gitExecutable . version , GitVersionRequirement . PushStash ) ) {
1234
+ return Promise . resolve ( constructIncompatibleGitVersionMessage ( this . gitExecutable , GitVersionRequirement . PushStash ) ) ;
1241
1235
}
1242
1236
1243
1237
let args = [ 'stash' , 'push' ] ;
@@ -1994,6 +1988,6 @@ interface GitTagDetailsData {
1994
1988
}
1995
1989
1996
1990
interface GpgStatusCodeParsingDetails {
1997
- status : GitSignatureStatus ,
1998
- uid : boolean
1991
+ readonly status : GitSignatureStatus ,
1992
+ readonly uid : boolean
1999
1993
}
0 commit comments