File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -685,6 +685,33 @@ public void CanSetTrackedBranch()
685
685
}
686
686
}
687
687
688
+ [ Fact ]
689
+ public void SetTrackedBranchForUnreasolvableRemoteThrows ( )
690
+ {
691
+ const string testBranchName = "branchToSetUpstreamInfoFor" ;
692
+ const string trackedBranchName = "refs/remotes/origin/master" ;
693
+ var fetchRefSpecs = new string [ ] { "+refs/heads/notfound/*:refs/remotes/origin/notfound/*" } ;
694
+
695
+ string path = CloneStandardTestRepo ( ) ;
696
+ using ( var repo = new Repository ( path ) )
697
+ {
698
+ // Modify the fetch spec so that the remote for the remote-tracking branch
699
+ // cannot be resolved.
700
+ Remote remote = repo . Network . Remotes [ "origin" ] ;
701
+ Assert . NotNull ( remote ) ;
702
+ repo . Network . Remotes . Update ( remote , r => r . FetchRefSpecs = fetchRefSpecs ) ;
703
+
704
+ // Now attempt to update the tracked branch
705
+ Branch branch = repo . CreateBranch ( testBranchName ) ;
706
+ Assert . False ( branch . IsTracking ) ;
707
+
708
+ Branch trackedBranch = repo . Branches [ trackedBranchName ] ;
709
+
710
+ Assert . Throws < LibGit2SharpException > ( ( ) => repo . Branches . Update ( branch ,
711
+ b => b . TrackedBranch = trackedBranch . CanonicalName ) ) ;
712
+ }
713
+ }
714
+
688
715
[ Fact ]
689
716
public void CanSetUpstreamBranch ( )
690
717
{
You can’t perform that action at this time.
0 commit comments