Exemple #1
0
    def search_repo(self, repo: github.Repository.Repository,
                    repo_out: github.Repository.Repository):
        repo_path = "/tmp/%s" % (repo.name)
        call([
            "git", "clone",
            "https://github.com/%s" % (repo.full_name), repo_path
        ])
        call(("git --git-dir %s/.git remote add output https://github.com/%s" %
              (repo_path, repo_out.full_name)).split(' '))
        call(["ls", "-l", repo_path])

        for pr_state in self._pr_state:
            prs = repo.get_pulls(state=pr_state, sort='updated')
            total = 0
            for _ in prs:
                total = total + 1
            for i, pr in enumerate(prs):
                print('[PR][%s][%d/%d]\t%s %s' %
                      (pr_state, i + 1, total, repo.name, pr.title))
                #print('Moved from: %s#%d' % (repo.full_name, pr.number))
                #print('Original author: @%s' % (pr.user.login))
                #print('Body: %s' % (pr.body))

                call(("git --git-dir %s/.git fetch origin pull/%d/head:%d" %
                      (repo_path, pr.number, pr.number)).split(' '))
                call(("git --git-dir %s/.git push output %d" %
                      (repo_path, pr.number)).split(' '))
                head = "%s:%d" % (repo_out.owner.login, pr.number)
                body = \
'''
%s

Moved from: %s#%d
Original author: @%s
''' % (pr.body, repo.full_name, pr.number, pr.user.login)

                repo_out.create_pull(title=pr.title,
                                     head=head,
                                     base="master",
                                     body=body)
Exemple #2
0
def open_pull_request(repo: github.Repository.Repository, branch_name: str,
                      default_branch: str) -> None:
    body = """
    #### This pull request was created automatically 🎉

    Before merging this PR:
    - [ ] Verify that all the tests pass.
    - [ ] Tag a release 
    """

    pull = repo.create_pull(
        title="[MagicBot] Bumping package version",
        body=body,
        head=branch_name,
        base=default_branch,
    )

    print(pull.html_url)