@@ -36,12 +36,8 @@ public void CanUnsetAnEntryFromTheLocalConfiguration()
36
36
[ Fact ]
37
37
public void CanUnsetAnEntryFromTheGlobalConfiguration ( )
38
38
{
39
- SelfCleaningDirectory scd = BuildSelfCleaningDirectory ( ) ;
40
-
41
- var options = BuildFakeConfigs ( scd ) ;
42
-
43
39
string path = SandboxBareTestRepo ( ) ;
44
- using ( var repo = new Repository ( path , options ) )
40
+ using ( var repo = new Repository ( path ) )
45
41
{
46
42
Assert . True ( repo . Config . HasConfig ( ConfigurationLevel . Global ) ) ;
47
43
Assert . Equal ( 42 , repo . Config . Get < int > ( "Wow.Man-I-am-totally-global" ) . Value ) ;
@@ -143,12 +139,10 @@ public void CanReadStringValue()
143
139
[ Fact ]
144
140
public void CanEnumerateGlobalConfig ( )
145
141
{
146
- string configPath = CreateConfigurationWithDummyUser ( Constants . Identity ) ;
147
- var options = new RepositoryOptions { GlobalConfigurationLocation = configPath } ;
148
-
149
142
var path = SandboxStandardTestRepoGitDir ( ) ;
150
- using ( var repo = new Repository ( path , options ) )
143
+ using ( var repo = new Repository ( path ) )
151
144
{
145
+ CreateConfigurationWithDummyUser ( repo , Constants . Identity ) ;
152
146
var entry = repo . Config . FirstOrDefault < ConfigurationEntry < string > > ( e => e . Key == "user.name" ) ;
153
147
Assert . NotNull ( entry ) ;
154
148
Assert . Equal ( Constants . Signature . Name , entry . Value ) ;
@@ -200,16 +194,14 @@ public void CanFindInLocalConfig()
200
194
[ Fact ]
201
195
public void CanFindInGlobalConfig ( )
202
196
{
203
- string configPath = CreateConfigurationWithDummyUser ( Constants . Identity ) ;
204
- var options = new RepositoryOptions { GlobalConfigurationLocation = configPath } ;
205
197
206
198
var path = SandboxStandardTestRepoGitDir ( ) ;
207
- using ( var repo = new Repository ( path , options ) )
199
+ using ( var repo = new Repository ( path ) )
208
200
{
209
- var matches = repo . Config . Find ( @"\.name ", ConfigurationLevel . Global ) ;
201
+ var matches = repo . Config . Find ( "-rocks ", ConfigurationLevel . Global ) ;
210
202
211
203
Assert . NotNull ( matches ) ;
212
- Assert . Equal ( new [ ] { "user.name " } ,
204
+ Assert . Equal ( new [ ] { "woot.this-rocks " } ,
213
205
matches . Select ( m => m . Key ) . ToArray ( ) ) ;
214
206
}
215
207
}
@@ -331,12 +323,8 @@ public void SettingUnsupportedTypeThrows()
331
323
[ Fact ]
332
324
public void CanGetAnEntryFromASpecificStore ( )
333
325
{
334
- SelfCleaningDirectory scd = BuildSelfCleaningDirectory ( ) ;
335
-
336
- var options = BuildFakeConfigs ( scd ) ;
337
-
338
326
string path = SandboxStandardTestRepo ( ) ;
339
- using ( var repo = new Repository ( path , options ) )
327
+ using ( var repo = new Repository ( path ) )
340
328
{
341
329
Assert . True ( repo . Config . HasConfig ( ConfigurationLevel . Local ) ) ;
342
330
Assert . True ( repo . Config . HasConfig ( ConfigurationLevel . Global ) ) ;
@@ -356,12 +344,8 @@ public void CanGetAnEntryFromASpecificStore()
356
344
[ Fact ]
357
345
public void CanTellIfASpecificStoreContainsAKey ( )
358
346
{
359
- SelfCleaningDirectory scd = BuildSelfCleaningDirectory ( ) ;
360
-
361
- var options = BuildFakeConfigs ( scd ) ;
362
-
363
347
string path = SandboxBareTestRepo ( ) ;
364
- using ( var repo = new Repository ( path , options ) )
348
+ using ( var repo = new Repository ( path ) )
365
349
{
366
350
Assert . True ( repo . Config . HasConfig ( ConfigurationLevel . System ) ) ;
367
351
@@ -387,16 +371,14 @@ public void CanAccessConfigurationWithoutARepository(Func<string, string> localC
387
371
{
388
372
var path = SandboxStandardTestRepoGitDir ( ) ;
389
373
390
- string globalConfigPath = CreateConfigurationWithDummyUser ( Constants . Identity ) ;
391
- var options = new RepositoryOptions { GlobalConfigurationLocation = globalConfigPath } ;
392
-
393
- using ( var repo = new Repository ( path , options ) )
374
+ using ( var repo = new Repository ( path ) )
394
375
{
395
376
repo . Config . Set ( "my.key" , "local" ) ;
396
377
repo . Config . Set ( "my.key" , "mouse" , ConfigurationLevel . Global ) ;
397
378
}
398
379
399
- using ( var config = Configuration . BuildFrom ( localConfigurationPathProvider ( path ) , globalConfigPath ) )
380
+ var globalPath = Path . Combine ( GlobalSettings . GetConfigSearchPaths ( ConfigurationLevel . Global ) . Single ( ) , ".gitconfig" ) ;
381
+ using ( var config = Configuration . BuildFrom ( localConfigurationPathProvider ( path ) , globalPath ) )
400
382
{
401
383
Assert . Equal ( "local" , config . Get < string > ( "my.key" ) . Value ) ;
402
384
Assert . Equal ( "mouse" , config . Get < string > ( "my.key" , ConfigurationLevel . Global ) . Value ) ;
@@ -418,11 +400,10 @@ public void PassingANonExistingLocalConfigurationFileToBuildFromthrowss()
418
400
public void CannotBuildAProperSignatureFromConfigWhenFullIdentityCannotBeFoundInTheConfig ( string name , string email )
419
401
{
420
402
string repoPath = InitNewRepository ( ) ;
421
- string configPath = CreateConfigurationWithDummyUser ( name , email ) ;
422
- var options = new RepositoryOptions { GlobalConfigurationLocation = configPath } ;
423
403
424
- using ( var repo = new Repository ( repoPath , options ) )
404
+ using ( var repo = new Repository ( repoPath ) )
425
405
{
406
+ CreateConfigurationWithDummyUser ( repo , name , email ) ;
426
407
Assert . Equal ( name , repo . Config . GetValueOrDefault < string > ( "user.name" ) ) ;
427
408
Assert . Equal ( email , repo . Config . GetValueOrDefault < string > ( "user.email" ) ) ;
428
409
0 commit comments