def load_project_to_repo(repo: Repository, branch: str = 'master') -> None: LOGGER.info(f"Start loading files to the repository {repo.full_name}") """ This method will load project to the repository :param repo: user's repo :param branch: branch to commit """ try: for file_path in project_files(os.getcwd()): with open(file_path) as f: content = f.read() repo_path = file_path.split('app')[-1] # get path to project files repo.create_file(path=repo_path[1:], message="initial_commit", content=content, branch=branch) except GithubException as e: LOGGER.error(f"Failed to load files repository due to error {e}") LOGGER.info(f"Files loaded to the repository {repo.full_name}")
def update_homebrew( homebrew_filename: str, version_str: str, github_repository: Repository, homebrew_tap_github_repository: Repository, ) -> None: """ Update a Homebrew file in a given Homebrew tap with an archive from a given repository. """ archive_url = github_repository.get_archive_link( archive_format='tarball', ref=version_str, ) new_recipe_contents = get_homebrew_formula( archive_url=archive_url, head_url=github_repository.clone_url, homebrew_recipe_filename=homebrew_filename, ) message = f'Homebrew recipe for version {version_str}' try: content_file = homebrew_tap_github_repository.get_contents( path=homebrew_filename, ref='master', ) except UnknownObjectException: homebrew_tap_github_repository.create_file( path=homebrew_filename, message=message, content=new_recipe_contents, ) else: # ``get_contents`` can return a ``ContentFile`` or a list of # ``ContentFile``s. assert isinstance(content_file, ContentFile) homebrew_tap_github_repository.update_file( path=homebrew_filename, message=message, content=new_recipe_contents, sha=content_file.sha, )