Пример #1
0
def gh_is_repo_empty(repo: Repository):
    from github import GithubException

    try:
        repo.get_file_contents('README.md')
    except GithubException as err:
        if err.status == 404:
            return err.data['message'] == 'This repository is empty.'
        else:
            raise err

    return False
Пример #2
0
 def _get_file_content_from_repository(github_repository: Repository,
                                       environment: str) -> Tuple[str, str]:
     try:
         content = github_repository.get_file_contents('/Puppetfile',
                                                       ref=environment)
         return content.decoded_content.decode('utf-8'), content.sha
     except GithubException:
         raise PuppetfileNotFoundException