@@ -219,3 +219,45 @@ def test_git_to_url(
219219 git_url .url = git_url .url .format (local_repo = git_repo .dir )
220220
221221 assert git_url .to_url () == expected
222+
223+
224+ class RevFixture (typing .NamedTuple ):
225+ git_url_kwargs : GitURLKwargs
226+ expected : typing .Optional [str ]
227+ # Expected revision / branch / tag
228+
229+
230+ @pytest .mark .parametrize (
231+ "git_url_kwargs,expected" ,
232+ [
233+ RevFixture (
234+ expected = None ,
235+ git_url_kwargs = GitURLKwargs (
236+ url = "git+ssh://git@bitbucket.example.com:7999/PROJ/repo.git" ,
237+ ),
238+ ),
239+ RevFixture (
240+ expected = "eucalyptus" ,
241+ git_url_kwargs = GitURLKwargs (
242+ url = "git+ssh://git@bitbucket.example.com:7999/PROJ/repo.git@eucalyptus" ,
243+ ),
244+ ),
245+ RevFixture (
246+ expected = "build.2600-whistler" ,
247+ git_url_kwargs = GitURLKwargs (
248+ url = "git+https://github.com/PROJ/repo.git@build.2600-whistler" ,
249+ ),
250+ ),
251+ ],
252+ )
253+ def test_git_revs (
254+ expected : str ,
255+ git_url_kwargs : GitURLKwargs ,
256+ ):
257+ class GitURLWithPip (GitURL ):
258+ matchers = MatcherRegistry = MatcherRegistry (
259+ _matchers = {m .label : m for m in [* DEFAULT_MATCHERS , * PIP_DEFAULT_MATCHERS ]}
260+ )
261+
262+ git_url = GitURLWithPip (** git_url_kwargs )
263+ assert git_url .rev == expected
0 commit comments