def create_or_edit_pr(title: str, body: str, skills_repo: Repository, user, branch: str): base = skills_repo.default_branch head = '{}:{}'.format(user.login, branch) pulls = list(skills_repo.get_pulls(base=base, head=head)) if pulls: pull = pulls[0] if 'mycroft-skills-kit' in pull.body: pull.edit(title, body) else: raise PRModified('Not updating description since it was not autogenerated') return pull else: return skills_repo.create_pull(title, body, base=base, head=head)
def create_or_edit_pr(title: str, body: str, skills_repo: Repository, user, branch: str, repo_branch: str): base = repo_branch head = '{}:{}'.format(user.login, branch) pulls = list(skills_repo.get_pulls(base=base, head=head)) if pulls: pull = pulls[0] if 'mycroft-skills-kit' in pull.body: pull.edit(title, body) else: raise PRModified('Not updating description since it was not autogenerated') return pull else: try: return skills_repo.create_pull(title, body, base=base, head=head) except GithubException as e: if e.status == 422: raise SkillNameTaken(title) from e raise