List matching references (#1471)

This commit is contained in:
Florent Clarret
2020-04-26 10:03:36 +08:00
committed by GitHub
parent 38b34db56e
commit d3bc6a5cd2
3 changed files with 56 additions and 0 deletions
+13
View File
@@ -2305,6 +2305,19 @@ class Repository(github.GithubObject.CompletableGithubObject):
github.GitRef.GitRef, self._requester, self.url + "/git/refs", None
)
def get_git_matching_refs(self, ref):
"""
:calls: `GET /repos/:owner/:repo/git/matching-refs/:ref <https://developer.github.com/v3/git/refs/#list-matching-references>`
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.GitRef.GitRef`
"""
assert isinstance(ref, str), ref
return github.PaginatedList.PaginatedList(
github.GitRef.GitRef,
self._requester,
self.url + "/git/matching-refs/" + ref,
None,
)
def get_git_tag(self, sha):
"""
:calls: `GET /repos/:owner/:repo/git/tags/:sha <http://developer.github.com/v3/git/tags>`_
File diff suppressed because one or more lines are too long
+10
View File
@@ -1647,6 +1647,16 @@ class Repository(Framework.TestCase):
repo = self.g.get_repo("protoncoin/protoncoin")
self.assertEqual(repo.full_name, "padima2/protoncoin")
def testGetMatchingRefs(self):
refs = self.g.get_repo("FlorentClarret/PyGithub").get_git_matching_refs("tags")
self.assertEqual(85, refs.totalCount)
self.assertEqual("refs/tags/v0.1", refs[0].ref)
self.assertEqual("refs/tags/v0.2", refs[1].ref)
self.assertEqual("refs/tags/v0.3", refs[2].ref)
self.assertEqual("refs/tags/v0.4", refs[3].ref)
self.assertEqual("refs/tags/v0.5", refs[4].ref)
self.assertEqual("refs/tags/v0.6", refs[5].ref)
class LazyRepository(Framework.TestCase):
def setUp(self):