@@ -190,5 +190,43 @@ public void SettingInvalidRefSpecsThrows(string refSpec)
190190 Assert . Equal ( oldRefSpecs , newRemote . RefSpecs . Select ( r => r . Specification ) . ToList ( ) ) ;
191191 }
192192 }
193+
194+ [ Theory ]
195+ [ InlineData ( "refs/heads/master" , true , false ) ]
196+ [ InlineData ( "refs/heads/some/master" , true , false ) ]
197+ [ InlineData ( "refs/remotes/foo/master" , false , true ) ]
198+ [ InlineData ( "refs/tags/foo" , false , false ) ]
199+ public void CanCheckForMatches ( string reference , bool shouldMatchSource , bool shouldMatchDest )
200+ {
201+ var path = SandboxStandardTestRepo ( ) ;
202+ using ( var repo = InitIsolatedRepository ( path ) )
203+ {
204+ var remote = repo . Network . Remotes . Add ( "foo" , "blahblah" , "refs/heads/*:refs/remotes/foo/*" ) ;
205+ var refspec = remote . RefSpecs . Single ( ) ;
206+
207+ Assert . Equal ( shouldMatchSource , refspec . SourceMatches ( reference ) ) ;
208+ Assert . Equal ( shouldMatchDest , refspec . DestinationMatches ( reference ) ) ;
209+ }
210+ }
211+
212+ [ Theory ]
213+ [ InlineData ( "refs/heads/master" , "refs/remotes/foo/master" ) ]
214+ [ InlineData ( "refs/heads/bar/master" , "refs/remotes/foo/bar/master" ) ]
215+ [ InlineData ( "refs/heads/master" , "refs/remotes/foo/master" ) ]
216+ public void CanTransformRefspecs ( string lhs , string rhs )
217+ {
218+ var path = SandboxStandardTestRepo ( ) ;
219+ using ( var repo = InitIsolatedRepository ( path ) )
220+ {
221+ var remote = repo . Network . Remotes . Add ( "foo" , "blahblah" , "refs/heads/*:refs/remotes/foo/*" ) ;
222+ var refspec = remote . RefSpecs . Single ( ) ;
223+
224+ var actualTransformed = refspec . Transform ( lhs ) ;
225+ var actualReverseTransformed = refspec . ReverseTransform ( rhs ) ;
226+
227+ Assert . Equal ( rhs , actualTransformed ) ;
228+ Assert . Equal ( lhs , actualReverseTransformed ) ;
229+ }
230+ }
193231 }
194232}
0 commit comments