@@ -238,7 +238,8 @@ public void CreatingABranchTriggersTheCreationOfADirectReference()
238
238
[ Fact ]
239
239
public void CreatingABranchFromANonCommitObjectThrows ( )
240
240
{
241
- using ( var repo = new Repository ( BareTestRepoPath ) )
241
+ string path = SandboxBareTestRepo ( ) ;
242
+ using ( var repo = new Repository ( path ) )
242
243
{
243
244
const string name = "sorry-dude-i-do-not-do-blobs-nor-trees" ;
244
245
Assert . Throws < InvalidSpecificationException > ( ( ) => repo . CreateBranch ( name , "refs/tags/point_to_blob" ) ) ;
@@ -250,7 +251,8 @@ public void CreatingABranchFromANonCommitObjectThrows()
250
251
[ Fact ]
251
252
public void CreatingBranchWithUnknownNamedTargetThrows ( )
252
253
{
253
- using ( var repo = new Repository ( BareTestRepoPath ) )
254
+ string path = SandboxBareTestRepo ( ) ;
255
+ using ( var repo = new Repository ( path ) )
254
256
{
255
257
Assert . Throws < LibGit2SharpException > ( ( ) => repo . Branches . Add ( "my_new_branch" , "my_old_branch" ) ) ;
256
258
}
@@ -259,7 +261,8 @@ public void CreatingBranchWithUnknownNamedTargetThrows()
259
261
[ Fact ]
260
262
public void CreatingBranchWithUnknownShaTargetThrows ( )
261
263
{
262
- using ( var repo = new Repository ( BareTestRepoPath ) )
264
+ string path = SandboxBareTestRepo ( ) ;
265
+ using ( var repo = new Repository ( path ) )
263
266
{
264
267
Assert . Throws < LibGit2SharpException > ( ( ) => repo . Branches . Add ( "my_new_branch" , Constants . UnknownSha ) ) ;
265
268
Assert . Throws < LibGit2SharpException > ( ( ) => repo . Branches . Add ( "my_new_branch" , Constants . UnknownSha . Substring ( 0 , 7 ) ) ) ;
@@ -269,7 +272,8 @@ public void CreatingBranchWithUnknownShaTargetThrows()
269
272
[ Fact ]
270
273
public void CreatingBranchWithBadParamsThrows ( )
271
274
{
272
- using ( var repo = new Repository ( BareTestRepoPath ) )
275
+ string path = SandboxBareTestRepo ( ) ;
276
+ using ( var repo = new Repository ( path ) )
273
277
{
274
278
Assert . Throws < ArgumentNullException > ( ( ) => repo . Branches . Add ( null , repo . Head . CanonicalName ) ) ;
275
279
Assert . Throws < ArgumentException > ( ( ) => repo . Branches . Add ( string . Empty , repo . Head . CanonicalName ) ) ;
@@ -282,7 +286,8 @@ public void CreatingBranchWithBadParamsThrows()
282
286
[ Fact ]
283
287
public void CanListAllBranches ( )
284
288
{
285
- using ( var repo = new Repository ( BareTestRepoPath ) )
289
+ string path = SandboxBareTestRepo ( ) ;
290
+ using ( var repo = new Repository ( path ) )
286
291
{
287
292
Assert . Equal ( expectedBranches , SortedBranches ( repo . Branches , b => b . Name ) ) ;
288
293
@@ -312,7 +317,8 @@ public void CanListBranchesWithRemoteAndLocalBranchWithSameShortName()
312
317
[ Fact ]
313
318
public void CanListAllBranchesWhenGivenWorkingDir ( )
314
319
{
315
- using ( var repo = new Repository ( StandardTestRepoWorkingDirPath ) )
320
+ string path = SandboxStandardTestRepo ( ) ;
321
+ using ( var repo = new Repository ( path ) )
316
322
{
317
323
var expectedWdBranches = new [ ]
318
324
{
@@ -328,7 +334,8 @@ public void CanListAllBranchesWhenGivenWorkingDir()
328
334
[ Fact ]
329
335
public void CanListAllBranchesIncludingRemoteRefs ( )
330
336
{
331
- using ( var repo = new Repository ( StandardTestRepoPath ) )
337
+ string path = SandboxStandardTestRepo ( ) ;
338
+ using ( var repo = new Repository ( path ) )
332
339
{
333
340
var expectedBranchesIncludingRemoteRefs = new [ ]
334
341
{
@@ -352,7 +359,8 @@ public void CanListAllBranchesIncludingRemoteRefs()
352
359
[ Fact ]
353
360
public void CanResolveRemote ( )
354
361
{
355
- using ( var repo = new Repository ( StandardTestRepoPath ) )
362
+ string path = SandboxStandardTestRepo ( ) ;
363
+ using ( var repo = new Repository ( path ) )
356
364
{
357
365
Branch master = repo . Branches [ "master" ] ;
358
366
Assert . Equal ( repo . Network . Remotes [ "origin" ] , master . Remote ) ;
@@ -362,7 +370,8 @@ public void CanResolveRemote()
362
370
[ Fact ]
363
371
public void RemoteAndUpstreamBranchCanonicalNameForNonTrackingBranchIsNull ( )
364
372
{
365
- using ( var repo = new Repository ( StandardTestRepoPath ) )
373
+ string path = SandboxStandardTestRepo ( ) ;
374
+ using ( var repo = new Repository ( path ) )
366
375
{
367
376
Branch test = repo . Branches [ "i-do-numbers" ] ;
368
377
Assert . Null ( test . Remote ) ;
@@ -374,7 +383,8 @@ public void RemoteAndUpstreamBranchCanonicalNameForNonTrackingBranchIsNull()
374
383
public void QueryRemoteForLocalTrackingBranch ( )
375
384
{
376
385
// There is not a Remote to resolve for a local tracking branch.
377
- using ( var repo = new Repository ( StandardTestRepoPath ) )
386
+ string path = SandboxStandardTestRepo ( ) ;
387
+ using ( var repo = new Repository ( path ) )
378
388
{
379
389
Branch trackLocal = repo . Branches [ "track-local" ] ;
380
390
Assert . Null ( trackLocal . Remote ) ;
@@ -384,7 +394,8 @@ public void QueryRemoteForLocalTrackingBranch()
384
394
[ Fact ]
385
395
public void QueryUpstreamBranchCanonicalNameForLocalTrackingBranch ( )
386
396
{
387
- using ( var repo = new Repository ( StandardTestRepoPath ) )
397
+ string path = SandboxStandardTestRepo ( ) ;
398
+ using ( var repo = new Repository ( path ) )
388
399
{
389
400
Branch trackLocal = repo . Branches [ "track-local" ] ;
390
401
Assert . Equal ( "refs/heads/master" , trackLocal . UpstreamBranchCanonicalName ) ;
@@ -394,7 +405,8 @@ public void QueryUpstreamBranchCanonicalNameForLocalTrackingBranch()
394
405
[ Fact ]
395
406
public void QueryRemoteForRemoteBranch ( )
396
407
{
397
- using ( var repo = new Repository ( StandardTestRepoPath ) )
408
+ string path = SandboxStandardTestRepo ( ) ;
409
+ using ( var repo = new Repository ( path ) )
398
410
{
399
411
var master = repo . Branches [ "origin/master" ] ;
400
412
Assert . Equal ( repo . Network . Remotes [ "origin" ] , master . Remote ) ;
@@ -452,7 +464,8 @@ public void QueryAmbigousRemoteForRemoteBranch()
452
464
[ Fact ]
453
465
public void CanLookupABranchByItsCanonicalName ( )
454
466
{
455
- using ( var repo = new Repository ( BareTestRepoPath ) )
467
+ string path = SandboxBareTestRepo ( ) ;
468
+ using ( var repo = new Repository ( path ) )
456
469
{
457
470
Branch branch = repo . Branches [ "refs/heads/br2" ] ;
458
471
Assert . NotNull ( branch ) ;
@@ -470,7 +483,8 @@ public void CanLookupABranchByItsCanonicalName()
470
483
[ Fact ]
471
484
public void CanLookupLocalBranch ( )
472
485
{
473
- using ( var repo = new Repository ( BareTestRepoPath ) )
486
+ string path = SandboxBareTestRepo ( ) ;
487
+ using ( var repo = new Repository ( path ) )
474
488
{
475
489
Branch master = repo . Branches [ "master" ] ;
476
490
Assert . NotNull ( master ) ;
@@ -501,7 +515,8 @@ public void CanLookupABranchWhichNameIsMadeOfNon7BitsAsciiCharacters()
501
515
[ Fact ]
502
516
public void LookingOutABranchByNameWithBadParamsThrows ( )
503
517
{
504
- using ( var repo = new Repository ( BareTestRepoPath ) )
518
+ string path = SandboxBareTestRepo ( ) ;
519
+ using ( var repo = new Repository ( path ) )
505
520
{
506
521
Branch branch ;
507
522
Assert . Throws < ArgumentNullException > ( ( ) => branch = repo . Branches [ null ] ) ;
@@ -587,7 +602,8 @@ public void TrackingInformationIsEmptyForBranchTrackingPrunedRemoteBranch()
587
602
[ Fact ]
588
603
public void TrackingInformationIsEmptyForNonTrackingBranch ( )
589
604
{
590
- using ( var repo = new Repository ( BareTestRepoPath ) )
605
+ string path = SandboxBareTestRepo ( ) ;
606
+ using ( var repo = new Repository ( path ) )
591
607
{
592
608
Branch branch = repo . Branches [ "test" ] ;
593
609
Assert . False ( branch . IsTracking ) ;
@@ -603,7 +619,8 @@ public void TrackingInformationIsEmptyForNonTrackingBranch()
603
619
[ Fact ]
604
620
public void CanGetTrackingInformationForTrackingBranch ( )
605
621
{
606
- using ( var repo = new Repository ( StandardTestRepoPath ) )
622
+ string path = SandboxStandardTestRepo ( ) ;
623
+ using ( var repo = new Repository ( path ) )
607
624
{
608
625
Branch master = repo . Branches [ "master" ] ;
609
626
Assert . True ( master . IsTracking ) ;
@@ -619,7 +636,8 @@ public void CanGetTrackingInformationForTrackingBranch()
619
636
[ Fact ]
620
637
public void CanGetTrackingInformationForLocalTrackingBranch ( )
621
638
{
622
- using ( var repo = new Repository ( StandardTestRepoPath ) )
639
+ string path = SandboxStandardTestRepo ( ) ;
640
+ using ( var repo = new Repository ( path ) )
623
641
{
624
642
var branch = repo . Branches [ "track-local" ] ;
625
643
Assert . True ( branch . IsTracking ) ;
@@ -635,7 +653,8 @@ public void CanGetTrackingInformationForLocalTrackingBranch()
635
653
[ Fact ]
636
654
public void RenamingARemoteTrackingBranchThrows ( )
637
655
{
638
- using ( var repo = new Repository ( StandardTestRepoPath ) )
656
+ string path = SandboxStandardTestRepo ( ) ;
657
+ using ( var repo = new Repository ( path ) )
639
658
{
640
659
Branch master = repo . Branches [ "refs/remotes/origin/master" ] ;
641
660
Assert . True ( master . IsRemote ) ;
@@ -647,7 +666,8 @@ public void RenamingARemoteTrackingBranchThrows()
647
666
[ Fact ]
648
667
public void CanWalkCommitsFromAnotherBranch ( )
649
668
{
650
- using ( var repo = new Repository ( BareTestRepoPath ) )
669
+ string path = SandboxBareTestRepo ( ) ;
670
+ using ( var repo = new Repository ( path ) )
651
671
{
652
672
Branch master = repo . Branches [ "test" ] ;
653
673
Assert . Equal ( 2 , master . Commits . Count ( ) ) ;
@@ -813,7 +833,8 @@ public void CanUnsetTrackedBranch()
813
833
[ Fact ]
814
834
public void CanWalkCommitsFromBranch ( )
815
835
{
816
- using ( var repo = new Repository ( BareTestRepoPath ) )
836
+ string path = SandboxBareTestRepo ( ) ;
837
+ using ( var repo = new Repository ( path ) )
817
838
{
818
839
Branch master = repo . Branches [ "master" ] ;
819
840
Assert . Equal ( 7 , master . Commits . Count ( ) ) ;
@@ -871,7 +892,8 @@ public void CanRemoveANonExistingBranch(string branchName, bool isRemote)
871
892
[ Fact ]
872
893
public void RemovingABranchWhichIsTheCurrentHeadThrows ( )
873
894
{
874
- using ( var repo = new Repository ( BareTestRepoPath ) )
895
+ string path = SandboxBareTestRepo ( ) ;
896
+ using ( var repo = new Repository ( path ) )
875
897
{
876
898
Assert . Throws < LibGit2SharpException > ( ( ) => repo . Branches . Remove ( repo . Head . Name ) ) ;
877
899
}
@@ -880,7 +902,8 @@ public void RemovingABranchWhichIsTheCurrentHeadThrows()
880
902
[ Fact ]
881
903
public void RemovingABranchWithBadParamsThrows ( )
882
904
{
883
- using ( var repo = new Repository ( BareTestRepoPath ) )
905
+ string path = SandboxBareTestRepo ( ) ;
906
+ using ( var repo = new Repository ( path ) )
884
907
{
885
908
Assert . Throws < ArgumentException > ( ( ) => repo . Branches . Remove ( string . Empty ) ) ;
886
909
Assert . Throws < ArgumentNullException > ( ( ) => repo . Branches . Remove ( null ) ) ;
@@ -890,7 +913,8 @@ public void RemovingABranchWithBadParamsThrows()
890
913
[ Fact ]
891
914
public void OnlyOneBranchIsTheHead ( )
892
915
{
893
- using ( var repo = new Repository ( BareTestRepoPath ) )
916
+ string path = SandboxBareTestRepo ( ) ;
917
+ using ( var repo = new Repository ( path ) )
894
918
{
895
919
Branch head = null ;
896
920
@@ -957,7 +981,8 @@ public void CanRenameABranch()
957
981
[ Fact ]
958
982
public void BlindlyRenamingABranchOverAnExistingOneThrows ( )
959
983
{
960
- using ( var repo = new Repository ( BareTestRepoPath ) )
984
+ string path = SandboxBareTestRepo ( ) ;
985
+ using ( var repo = new Repository ( path ) )
961
986
{
962
987
Assert . Throws < NameConflictException > ( ( ) => repo . Branches . Rename ( "br2" , "test" ) ) ;
963
988
}
@@ -1068,7 +1093,8 @@ public void TrackedBranchExistsFromDefaultConfigInEmptyClone()
1068
1093
[ Fact ]
1069
1094
public void RemoteBranchesDoNotTrackAnything ( )
1070
1095
{
1071
- using ( var repo = new Repository ( StandardTestRepoPath ) )
1096
+ string path = SandboxStandardTestRepo ( ) ;
1097
+ using ( var repo = new Repository ( path ) )
1072
1098
{
1073
1099
var branches = repo . Branches . Where ( b => b . IsRemote ) ;
1074
1100
0 commit comments