@@ -259,12 +259,13 @@ public void CanResolveRemote()
259
259
}
260
260
261
261
[ Fact ]
262
- public void RemoteForNonTrackingBranchIsNull ( )
262
+ public void RemoteAndUpstreamBranchCanonicalNameForNonTrackingBranchIsNull ( )
263
263
{
264
264
using ( var repo = new Repository ( StandardTestRepoPath ) )
265
265
{
266
266
Branch test = repo . Branches [ "i-do-numbers" ] ;
267
267
Assert . Null ( test . Remote ) ;
268
+ Assert . Null ( test . UpstreamBranchCanonicalName ) ;
268
269
}
269
270
}
270
271
@@ -279,6 +280,16 @@ public void QueryRemoteForLocalTrackingBranch()
279
280
}
280
281
}
281
282
283
+ [ Fact ]
284
+ public void QueryUpstreamBranchCanonicalNameForLocalTrackingBranch ( )
285
+ {
286
+ using ( var repo = new Repository ( StandardTestRepoPath ) )
287
+ {
288
+ Branch trackLocal = repo . Branches [ "track-local" ] ;
289
+ Assert . Equal ( "refs/heads/master" , trackLocal . UpstreamBranchCanonicalName ) ;
290
+ }
291
+ }
292
+
282
293
[ Fact ]
283
294
public void CanLookupABranchByItsCanonicalName ( )
284
295
{
@@ -454,20 +465,20 @@ public void CanWalkCommitsFromAnotherBranch()
454
465
}
455
466
456
467
[ Fact ]
457
- public void CanSetUpstreamBranch ( )
468
+ public void CanSetTrackedBranch ( )
458
469
{
459
470
const string testBranchName = "branchToSetUpstreamInfoFor" ;
460
- const string upstreamBranchName = "refs/remotes/origin/master" ;
471
+ const string trackedBranchName = "refs/remotes/origin/master" ;
461
472
462
473
string path = CloneStandardTestRepo ( ) ;
463
474
using ( var repo = new Repository ( path ) )
464
475
{
465
476
Branch branch = repo . CreateBranch ( testBranchName ) ;
466
477
Assert . False ( branch . IsTracking ) ;
467
478
468
- Branch upstreamBranch = repo . Branches [ upstreamBranchName ] ;
479
+ Branch trackedBranch = repo . Branches [ trackedBranchName ] ;
469
480
repo . Branches . Update ( branch ,
470
- b => b . Upstream = upstreamBranch . CanonicalName ) ;
481
+ b => b . TrackedBranch = trackedBranch . CanonicalName ) ;
471
482
472
483
// Verify the immutability of the branch.
473
484
Assert . False ( branch . IsTracking ) ;
@@ -479,58 +490,59 @@ public void CanSetUpstreamBranch()
479
490
Assert . NotNull ( upstreamRemote ) ;
480
491
481
492
Assert . True ( branch . IsTracking ) ;
482
- Assert . Equal ( upstreamBranch , branch . TrackedBranch ) ;
493
+ Assert . Equal ( trackedBranch , branch . TrackedBranch ) ;
483
494
Assert . Equal ( upstreamRemote , branch . Remote ) ;
484
495
}
485
496
}
486
497
487
498
[ Fact ]
488
- public void CanSetUpstreamMergeBranch ( )
499
+ public void CanSetUpstreamBranch ( )
489
500
{
490
501
const string testBranchName = "branchToSetUpstreamInfoFor" ;
491
- const string mergeBranchName = "refs/heads/master" ;
492
- const string upstreamBranchName = "refs/remotes/origin/master" ;
493
- const string upstreamRemoteName = "origin" ;
502
+ const string upstreamBranchName = "refs/heads/master" ;
503
+ const string trackedBranchName = "refs/remotes/origin/master" ;
504
+ const string remoteName = "origin" ;
494
505
495
506
string path = CloneStandardTestRepo ( ) ;
496
507
using ( var repo = new Repository ( path ) )
497
508
{
498
509
Branch branch = repo . CreateBranch ( testBranchName ) ;
499
510
Assert . False ( branch . IsTracking ) ;
500
511
501
- Branch upstreamBranch = repo . Branches [ upstreamBranchName ] ;
512
+ Branch trackedBranch = repo . Branches [ trackedBranchName ] ;
502
513
Branch updatedBranch = repo . Branches . Update ( branch ,
503
- b => b . UpstreamRemote = upstreamRemoteName ,
504
- b => b . UpstreamMergeBranch = mergeBranchName ) ;
514
+ b => b . Remote = remoteName ,
515
+ b => b . UpstreamBranch = upstreamBranchName ) ;
505
516
506
517
// Verify the immutability of the branch.
507
518
Assert . False ( branch . IsTracking ) ;
508
519
509
- Remote upstreamRemote = repo . Network . Remotes [ upstreamRemoteName ] ;
520
+ Remote upstreamRemote = repo . Network . Remotes [ remoteName ] ;
510
521
Assert . NotNull ( upstreamRemote ) ;
511
522
512
523
Assert . True ( updatedBranch . IsTracking ) ;
513
- Assert . Equal ( upstreamBranch , updatedBranch . TrackedBranch ) ;
524
+ Assert . Equal ( trackedBranch , updatedBranch . TrackedBranch ) ;
525
+ Assert . Equal ( upstreamBranchName , updatedBranch . UpstreamBranchCanonicalName ) ;
514
526
Assert . Equal ( upstreamRemote , updatedBranch . Remote ) ;
515
527
}
516
528
}
517
529
518
530
[ Fact ]
519
- public void CanSetLocalUpstreamBranch ( )
531
+ public void CanSetLocalTrackedBranch ( )
520
532
{
521
533
const string testBranchName = "branchToSetUpstreamInfoFor" ;
522
- const string upstreamBranchName = "refs/heads/master" ;
534
+ const string localTrackedBranchName = "refs/heads/master" ;
523
535
524
536
string path = CloneStandardTestRepo ( ) ;
525
537
using ( var repo = new Repository ( path ) )
526
538
{
527
539
Branch branch = repo . CreateBranch ( testBranchName ) ;
528
540
Assert . False ( branch . IsTracking ) ;
529
541
530
- Branch upstreamBranch = repo . Branches [ upstreamBranchName ] ;
542
+ Branch trackedBranch = repo . Branches [ localTrackedBranchName ] ;
531
543
532
544
repo . Branches . Update ( branch ,
533
- b => b . Upstream = upstreamBranch . CanonicalName ) ;
545
+ b => b . TrackedBranch = trackedBranch . CanonicalName ) ;
534
546
535
547
// Get the updated branch information.
536
548
branch = repo . Branches [ testBranchName ] ;
@@ -548,15 +560,16 @@ public void CanSetLocalUpstreamBranch()
548
560
549
561
// Verify the IsTracking and TrackedBranch properties.
550
562
Assert . True ( branch . IsTracking ) ;
551
- Assert . Equal ( upstreamBranch , branch . TrackedBranch ) ;
563
+ Assert . Equal ( trackedBranch , branch . TrackedBranch ) ;
564
+ Assert . Equal ( "refs/heads/master" , branch . UpstreamBranchCanonicalName ) ;
552
565
}
553
566
}
554
567
555
568
[ Fact ]
556
- public void CanUnsetUpstreamBranch ( )
569
+ public void CanUnsetTrackedBranch ( )
557
570
{
558
571
const string testBranchName = "branchToSetUpstreamInfoFor" ;
559
- const string upstreamBranchName = "refs/remotes/origin/master" ;
572
+ const string trackedBranchName = "refs/remotes/origin/master" ;
560
573
561
574
string path = CloneStandardTestRepo ( ) ;
562
575
using ( var repo = new Repository ( path ) )
@@ -565,16 +578,18 @@ public void CanUnsetUpstreamBranch()
565
578
Assert . False ( branch . IsTracking ) ;
566
579
567
580
branch = repo . Branches . Update ( branch ,
568
- b => b . Upstream = upstreamBranchName ) ;
581
+ b => b . TrackedBranch = trackedBranchName ) ;
569
582
570
583
// Got the updated branch from the Update() method
571
584
Assert . True ( branch . IsTracking ) ;
572
585
573
586
branch = repo . Branches . Update ( branch ,
574
- b => b . Upstream = null ) ;
587
+ b => b . TrackedBranch = null ) ;
575
588
576
589
// Verify this is no longer a tracking branch
577
590
Assert . False ( branch . IsTracking ) ;
591
+ Assert . Null ( branch . Remote ) ;
592
+ Assert . Null ( branch . UpstreamBranchCanonicalName ) ;
578
593
}
579
594
}
580
595
0 commit comments