def list(self, pattern):
res = self._EXTRACT_PATTERN.match(pattern)
if not res:
raise URIException(f"Unable to match {pattern},"
" please use 'organization[/repo_pattern]'")
org_name = res.group("org")
repo_matcher = res.group("repo") or "*"
try:
repos = self._gh.get_organization(org_name).get_repos()
except github.GithubException:
repos = self._gh.get_user(org_name).get_repos()
for repo in repos:
if not fnmatch.fnmatch(repo.name, repo_matcher):
continue
if self._clone_protocol == self.CloneProtocol.ssh:
yield Repo(name=repo.name, url=repo.ssh_url)
elif self._clone_protocol == self.CloneProtocol.https:
yield Repo(name=repo.name, url=repo.clone_url)
else:
raise RuntimeError(f"Invalid protocol selected: {self._clone_protocol}")
评论列表
文章目录