コード例 #1
0
def merge_pr(num, github_api=3):
    """ try to merge the branch of PR `num` into current branch
    
    github_api : use github api v2 (to bypass https and issues with proxy) to find the
             remote branch that should be merged by it's number
    """
    # Get Github authorisation first, so that the user is prompted straight away
    # if their login is needed.
    
    pr = gh_api.get_pull_request(gh_project, num, github_api)
    if github_api == 2:
        repo = pr['head']['repository']['url']
    elif github_api == 3 :
        repo = pr['head']['repo']['clone_url']


    branch = pr['head']['ref']
    mergeable = merge_branch(repo=repo, 
                 branch=branch,
              )
    if not mergeable :
        cmd = "git pull "+repo+" "+branch
        not_merged[str(num)] = cmd
        print("==============================================================================")
        print("Something went wrong merging this branch, you can try it manually by runngin :")
        print(cmd)
        print("==============================================================================")
コード例 #2
0
def should_backport(labels=None, milestone=None, project="ipython/ipython"):
    """return set of PRs marked for backport"""
    if labels is None and milestone is None:
        raise ValueError("Specify one of labels or milestone.")
    elif labels is not None and milestone is not None:
        raise ValueError("Specify only one of labels or milestone.")
    if labels is not None:
        issues = get_issues_list(project,
                                 labels=labels,
                                 state="closed",
                                 auth=True)
    else:
        milestone_id = get_milestone_id(project, milestone, auth=True)
        issues = get_issues_list(project,
                                 milestone=milestone_id,
                                 state="closed",
                                 auth=True)

    should_backport = set()
    for issue in issues:
        if not is_pull_request(issue):
            continue
        pr = get_pull_request(project, issue["number"], auth=True)
        if not pr["merged"]:
            print("Marked PR closed without merge: %i" % pr["number"])
            continue
        if pr["base"]["ref"] != "master":
            continue
        should_backport.add(pr["number"])
    return should_backport
コード例 #3
0
def should_backport(labels=None, milestone=None):
    """return set of PRs marked for backport"""
    if labels is None and milestone is None:
        raise ValueError("Specify one of labels or milestone.")
    elif labels is not None and milestone is not None:
        raise ValueError("Specify only one of labels or milestone.")
    if labels is not None:
        issues = get_issues_list("statsmodels/statsmodels",
                                 labels=labels,
                                 state='closed',
                                 auth=True)
    else:
        milestone_id = get_milestone_id("statsmodels/statsmodels",
                                        milestone,
                                        auth=True)
        issues = get_issues_list("statsmodels/statsmodels",
                                 milestone=milestone_id,
                                 state='closed',
                                 auth=True)

    should_backport = []
    merged_dates = []
    for issue in issues:
        if not is_pull_request(issue):
            continue
        pr = get_pull_request("statsmodels/statsmodels",
                              issue['number'],
                              auth=True)
        if not pr['merged']:
            print("Marked PR closed without merge: %i" % pr['number'])
            continue
        if pr['number'] not in should_backport:
            merged_dates.append(pr['merged_at'])
            should_backport.append(pr['number'])
    return Series(merged_dates, index=should_backport)
コード例 #4
0
ファイル: backport_pr.py プロジェクト: 0ceangypsy/statsmodels
def should_backport(labels=None, milestone=None):
    """return set of PRs marked for backport"""
    if labels is None and milestone is None:
        raise ValueError("Specify one of labels or milestone.")
    elif labels is not None and milestone is not None:
        raise ValueError("Specify only one of labels or milestone.")
    if labels is not None:
        issues = get_issues_list("statsmodels/statsmodels",
                labels=labels,
                state='closed',
                auth=True,
        )
    else:
        milestone_id = get_milestone_id("statsmodels/statsmodels", milestone,
                auth=True)
        issues = get_issues_list("statsmodels/statsmodels",
                milestone=milestone_id,
                state='closed',
                auth=True,
        )

    should_backport = []
    merged_dates = []
    for issue in issues:
        if not is_pull_request(issue):
            continue
        pr = get_pull_request("statsmodels/statsmodels", issue['number'],
                auth=True)
        if not pr['merged']:
            print ("Marked PR closed without merge: %i" % pr['number'])
            continue
        if pr['number'] not in should_backport:
            merged_dates.append(pr['merged_at'])
            should_backport.append(pr['number'])
    return Series(merged_dates, index=should_backport)
コード例 #5
0
def merge_pr(num):
    """ try to merge the branch of PR `num` into current branch
    """
    # Get Github authorisation first, so that the user is prompted straight away
    # if their login is needed.

    pr = gh_api.get_pull_request(gh_project, num)
    repo = pr['head']['repo']['clone_url']

    branch = pr['head']['ref']
    mergeable = merge_branch(
        repo=repo,
        branch=branch,
    )
    if not mergeable:
        cmd = "git pull " + repo + " " + branch
        not_merged[str(num)] = cmd
        print(
            "=============================================================================="
        )
        print(
            "Something went wrong merging this branch, you can try it manually by runngin :"
        )
        print(cmd)
        print(
            "=============================================================================="
        )
コード例 #6
0
def should_backport(labels=None, milestone=None):
    """return set of PRs marked for backport"""
    if labels is None and milestone is None:
        raise ValueError("Specify one of labels or milestone.")
    elif labels is not None and milestone is not None:
        raise ValueError("Specify only one of labels or milestone.")
    if labels is not None:
        issues = get_issues_list("ipython/ipython",
                labels=labels,
                state='closed',
                auth=True,
        )
    else:
        milestone_id = get_milestone_id("ipython/ipython", milestone,
                auth=True)
        issues = get_issues_list("ipython/ipython",
                milestone=milestone_id,
                state='closed',
                auth=True,
        )

    should_backport = set()
    for issue in issues:
        if not is_pull_request(issue):
            continue
        pr = get_pull_request("ipython/ipython", issue['number'],
                auth=True)
        if not pr['merged']:
            print ("Marked PR closed without merge: %i" % pr['number'])
            continue
        should_backport.add(pr['number'])
    return should_backport
コード例 #7
0
def main(*args):
    parser = argparse.ArgumentParser(description="""
                Merge one or more github pull requests by their number. If any
                one pull request can't be merged as is, its merge is ignored
                and the process continues with the next ones (if any).
                """)

    grp = parser.add_mutually_exclusive_group()
    grp.add_argument('-l',
                     '--list',
                     action='store_const',
                     const=True,
                     help='list PR, their number and their mergeability')
    grp.add_argument('-a',
                     '--merge-all',
                     action='store_const',
                     const=True,
                     help='try to merge as many PR as possible, one by one')
    parser.add_argument('merge',
                        type=int,
                        help="The pull request numbers",
                        nargs='*',
                        metavar='pr-number')
    args = parser.parse_args()

    if (args.list):
        pr_list = gh_api.get_pulls_list(gh_project)
        for pr in pr_list:
            mergeable = gh_api.get_pull_request(gh_project,
                                                pr['number'])['mergeable']

            ismgb = u"√" if mergeable else " "
            print(u"* #{number} [{ismgb}]:  {title}".format(
                number=pr['number'], title=pr['title'], ismgb=ismgb))

    if (args.merge_all):
        branch_name = 'merge-' + '-'.join(str(pr['number']) for pr in pr_list)
        git_new_branch(branch_name)
        pr_list = gh_api.get_pulls_list(gh_project)
        for pr in pr_list:
            merge_pr(pr['number'])

    elif args.merge:
        branch_name = 'merge-' + '-'.join(map(str, args.merge))
        git_new_branch(branch_name)
        for num in args.merge:
            merge_pr(num)

    if not_merged:
        print(
            '*************************************************************************************'
        )
        print(
            'The following branch has not been merged automatically, consider doing it by hand   :'
        )
        for num, cmd in not_merged.items():
            print("PR {num}: {cmd}".format(num=num, cmd=cmd))
        print(
            '*************************************************************************************'
        )
コード例 #8
0
def backport_pr(branch, num, project='ipython/ipython'):
    current_branch = get_current_branch()
    if branch != current_branch:
        check_call(['git', 'checkout', branch])
    check_call(['git', 'pull'])
    pr = get_pull_request(project, num, auth=True)
    files = get_pull_request_files(project, num, auth=True)
    patch_url = pr['patch_url']
    title = pr['title']
    description = pr['body'] or ''
    fname = "PR%i.patch" % num
    if os.path.exists(fname):
        print("using patch from {fname}".format(**locals()))
        with open(fname, 'rb') as f:
            patch = f.read()
    else:
        req = urlopen(patch_url)
        patch = req.read()

    lines = description.splitlines()
    if len(lines) > 5:
        lines = lines[:5] + ['...']
        description = '\n'.join(lines)

    msg = "Backport PR #%i: %s" % (num, title) + '\n\n' + description
    check = Popen(['git', 'apply', '--check', '--verbose'], stdin=PIPE)
    a, b = check.communicate(patch)

    if check.returncode:
        print("patch did not apply, saving to {fname}".format(**locals()))
        print("edit {fname} until `cat {fname} | git apply --check` succeeds".
              format(**locals()))
        print("then run tools/backport_pr.py {num} again".format(**locals()))
        if not os.path.exists(fname):
            with open(fname, 'wb') as f:
                f.write(patch)
        return 1

    p = Popen(['git', 'apply'], stdin=PIPE)
    a, b = p.communicate(patch)

    filenames = [f['filename'] for f in files]
    filenames = [
        f.replace('jupyter_notebook', 'IPython/html') for f in filenames
    ]

    check_call(['git', 'add'] + filenames)

    check_call(['git', 'commit', '-m', msg])

    print("PR #%i applied, with msg:" % num)
    print()
    print(msg)
    print()

    if branch != current_branch:
        check_call(['git', 'checkout', current_branch])

    return 0
コード例 #9
0
ファイル: git-mpr.py プロジェクト: Carreau/ipython
def main(*args):
    parser = argparse.ArgumentParser(
            description="""
                Merge one or more github pull requests by their number. If any
                one pull request can't be merged as is, its merge is ignored
                and the process continues with the next ones (if any).
                """
            )

    grp = parser.add_mutually_exclusive_group()
    grp.add_argument(
            '-l',
            '--list',
            action='store_const',
            const=True,
            help='list PR, their number and their mergeability')
    grp.add_argument('-a',
            '--merge-all',
            action='store_const',
            const=True ,
            help='try to merge as many PR as possible, one by one')
    parser.add_argument('merge',
            type=int,
            help="The pull request numbers",
            nargs='*',
            metavar='pr-number')
    args = parser.parse_args()

    if(args.list):
        pr_list = gh_api.get_pulls_list(gh_project)
        for pr in pr_list :
            mergeable = gh_api.get_pull_request(gh_project, pr['number'])['mergeable']

            ismgb = u"√" if mergeable else " "
            print(u"* #{number} [{ismgb}]:  {title}".format(
                number=pr['number'],
                title=pr['title'],
                ismgb=ismgb))

    if(args.merge_all):
        branch_name = 'merge-' + '-'.join(str(pr['number']) for pr in pr_list)
        git_new_branch(branch_name)
        pr_list = gh_api.get_pulls_list(gh_project)
        for pr in pr_list :
            merge_pr(pr['number'])


    elif args.merge:
        branch_name = 'merge-' + '-'.join(map(str, args.merge))
        git_new_branch(branch_name)
        for num in args.merge :
            merge_pr(num)

    if not_merged :
        print('*************************************************************************************')
        print('The following branch has not been merged automatically, consider doing it by hand   :')
        for num, cmd in not_merged.items() :
            print( "PR {num}: {cmd}".format(num=num, cmd=cmd))
        print('*************************************************************************************')
コード例 #10
0
ファイル: github_stats_1.2.py プロジェクト: minrk/script-dump
def get_authors(issue):
    print("getting authors for #%i" % issue['number'], file=sys.stderr)
    pr = get_pull_request('ipython/ipython', issue['number'], auth=True)
    commits = api_request(pr['commits_url'], auth=True)
    authors = []
    for commit in commits:
        author = commit['commit']['author']
        authors.append("%s <%s>" % (author['name'], author['email']))
    return authors
コード例 #11
0
def backport_pr(branch, num, project="ipython/ipython"):
    current_branch = get_current_branch()
    if branch != current_branch:
        check_call(["git", "checkout", branch])
    check_call(["git", "pull"])
    pr = get_pull_request(project, num, auth=True)
    files = get_pull_request_files(project, num, auth=True)
    patch_url = pr["patch_url"]
    title = pr["title"]
    description = pr["body"]
    fname = "PR%i.patch" % num
    if os.path.exists(fname):
        print("using patch from {fname}".format(**locals()))
        with open(fname, "rb") as f:
            patch = f.read()
    else:
        req = urlopen(patch_url)
        patch = req.read()

    lines = description.splitlines()
    if len(lines) > 5:
        lines = lines[:5] + ["..."]
        description = "\n".join(lines)

    msg = "Backport PR #%i: %s" % (num, title) + "\n\n" + description
    check = Popen(["git", "apply", "--check", "--verbose"], stdin=PIPE)
    a, b = check.communicate(patch)

    if check.returncode:
        print("patch did not apply, saving to {fname}".format(**locals()))
        print("edit {fname} until `cat {fname} | git apply --check` succeeds".
              format(**locals()))
        print("then run tools/backport_pr.py {num} again".format(**locals()))
        if not os.path.exists(fname):
            with open(fname, "wb") as f:
                f.write(patch)
        return 1

    p = Popen(["git", "apply"], stdin=PIPE)
    a, b = p.communicate(patch)

    filenames = [f["filename"] for f in files]

    check_call(["git", "add"] + filenames)

    check_call(["git", "commit", "-m", msg])

    print("PR #%i applied, with msg:" % num)
    print()
    print(msg)
    print()

    if branch != current_branch:
        check_call(["git", "checkout", current_branch])

    return 0
コード例 #12
0
ファイル: backport_pr.py プロジェクト: quantopian/ipython
def backport_pr(branch, num, project='ipython/ipython'):
    current_branch = get_current_branch()
    if branch != current_branch:
        check_call(['git', 'checkout', branch])
    check_call(['git', 'pull'])
    pr = get_pull_request(project, num, auth=True)
    files = get_pull_request_files(project, num, auth=True)
    patch_url = pr['patch_url']
    title = pr['title']
    description = pr['body'] or ''
    fname = "PR%i.patch" % num
    if os.path.exists(fname):
        print("using patch from {fname}".format(**locals()))
        with open(fname, 'rb') as f:
            patch = f.read()
    else:
        req = urlopen(patch_url)
        patch = req.read()

    lines = description.splitlines()
    if len(lines) > 5:
        lines = lines[:5] + ['...']
        description = '\n'.join(lines)

    msg = "Backport PR #%i: %s" % (num, title) + '\n\n' + description
    check = Popen(['git', 'apply', '--check', '--verbose'], stdin=PIPE)
    a,b = check.communicate(patch)

    if check.returncode:
        print("patch did not apply, saving to {fname}".format(**locals()))
        print("edit {fname} until `cat {fname} | git apply --check` succeeds".format(**locals()))
        print("then run tools/backport_pr.py {num} again".format(**locals()))
        if not os.path.exists(fname):
            with open(fname, 'wb') as f:
                f.write(patch)
        return 1

    p = Popen(['git', 'apply'], stdin=PIPE)
    a,b = p.communicate(patch)

    filenames = [ f['filename'] for f in files ]
    filenames = [ f.replace('jupyter_notebook', 'IPython/html') for f in filenames ]

    check_call(['git', 'add'] + filenames)

    check_call(['git', 'commit', '-m', msg])

    print("PR #%i applied, with msg:" % num)
    print()
    print(msg)
    print()

    if branch != current_branch:
        check_call(['git', 'checkout', current_branch])

    return 0
コード例 #13
0
ファイル: test_pr.py プロジェクト: yanchao727/ipython
 def __init__(self, pr_num):
     self.unavailable_pythons = []
     self.venvs = []
     self.pr_num = pr_num
     
     self.pr = gh_api.get_pull_request(gh_project, pr_num)
     
     self.setup()
     
     self.results = []
コード例 #14
0
    def __init__(self, pr_num):
        self.unavailable_pythons = []
        self.venvs = []
        self.pr_num = pr_num

        self.pr = gh_api.get_pull_request(gh_project, pr_num)

        self.setup()

        self.results = []
コード例 #15
0
ファイル: github_stats.py プロジェクト: Xaerxess/ipython
def split_pulls(all_issues, project="ipython/ipython"):
    """split a list of closed issues into non-PR Issues and Pull Requests"""
    pulls = []
    issues = []
    for i in all_issues:
        if is_pull_request(i):
            pull = get_pull_request(project, i['number'], auth=True)
            pulls.append(pull)
        else:
            issues.append(i)
    return issues, pulls
コード例 #16
0
ファイル: github_stats.py プロジェクト: kikuriyou/example
def split_pulls(all_issues, project="statsmodels/statsmodels"):
    """split a list of closed issues into non-PR Issues and Pull Requests"""
    pulls = []
    issues = []
    for i in all_issues:
        if is_pull_request(i):
            pull = get_pull_request(project, i['number'], auth=True)
            pulls.append(pull)
        else:
            issues.append(i)
    return issues, pulls
コード例 #17
0
def backport_pr(branch, num, project="statsmodels/statsmodels"):
    current_branch = get_current_branch()
    if branch != current_branch:
        check_call(["git", "checkout", branch])
    check_call(["git", "pull"])
    pr = get_pull_request(project, num, auth=True)
    files = get_pull_request_files(project, num, auth=True)
    patch_url = pr["patch_url"]
    title = pr["title"]
    description = pr["body"]
    fname = "PR%i.patch" % num
    if os.path.exists(fname):
        print("using patch from {fname}".format(**locals()))
        with open(fname) as f:
            patch = f.read()
    else:
        req = urlopen(patch_url)
        patch = req.read()

    msg = "Backport PR #%i: %s" % (num, title) + "\n\n" + description
    check = Popen(["git", "apply", "--check", "--verbose"], stdin=PIPE)
    a, b = check.communicate(patch)

    if check.returncode:
        print("patch did not apply, saving to {fname}".format(**locals()))
        print("edit {fname} until `cat {fname} | git apply --check` succeeds".format(**locals()))
        print("then run tools/backport_pr.py {num} again".format(**locals()))
        if not os.path.exists(fname):
            with open(fname, "wb") as f:
                f.write(patch)
        return 1

    p = Popen(["git", "apply"], stdin=PIPE)
    a, b = p.communicate(patch)

    filenames = [f["filename"] for f in files]

    check_call(["git", "add"] + filenames)

    check_call(["git", "commit", "-m", msg])

    print("PR #%i applied, with msg:" % num)
    print()
    print(msg)
    print()

    if branch != current_branch:
        check_call(["git", "checkout", current_branch])

    return 0
コード例 #18
0
ファイル: backport_pr.py プロジェクト: yumei165/ipython
def backport_pr(branch, num, project='ipython/ipython'):
    current_branch = get_current_branch()
    if branch != current_branch:
        check_call(['git', 'checkout', branch])
    pr = get_pull_request(project, num)
    patch_url = pr['patch_url']
    title = pr['title']
    description = pr['body']
    fname = "PR%i.patch" % num
    if os.path.exists(fname):
        print("using patch from {fname}".format(**locals()))
        with open(fname) as f:
            patch = f.read()
    else:
        req = urlopen(patch_url)
        patch = req.read()

    msg = "Backport PR #%i: %s" % (num, title) + '\n\n' + description
    check = Popen(['git', 'apply', '--check', '--verbose'], stdin=PIPE)
    a, b = check.communicate(patch)

    if check.returncode:
        print("patch did not apply, saving to {fname}".format(**locals()))
        print("edit {fname} until `cat {fname} | git apply --check` succeeds".
              format(**locals()))
        print("then run tools/backport_pr.py {num} again".format(**locals()))
        if not os.path.exists(fname):
            with open(fname, 'wb') as f:
                f.write(patch)
        return 1

    p = Popen(['git', 'apply'], stdin=PIPE)
    a, b = p.communicate(patch)

    commit = Popen(['git', 'commit', '-a', '-m', msg])
    commit.communicate()
    if commit.returncode:
        print("commit failed!")
        return 1
    else:
        print("PR #%i applied, with msg:" % num)
        print()
        print(msg)
        print()

    if branch != current_branch:
        check_call(['git', 'checkout', current_branch])

    return 0
コード例 #19
0
ファイル: backport_pr.py プロジェクト: 3kwa/ipython
def backport_pr(branch, num, project='ipython/ipython'):
    current_branch = get_current_branch()
    if branch != current_branch:
        check_call(['git', 'checkout', branch])
    pr = get_pull_request(project, num)
    patch_url = pr['patch_url']
    title = pr['title']
    description = pr['body']
    fname = "PR%i.patch" % num
    if os.path.exists(fname):
        print("using patch from {fname}".format(**locals()))
        with open(fname) as f:
            patch = f.read()
    else:
        req = urlopen(patch_url)
        patch = req.read()
    
    msg = "Backport PR #%i: %s" % (num, title) + '\n\n' + description
    check = Popen(['git', 'apply', '--check', '--verbose'], stdin=PIPE)
    a,b = check.communicate(patch)
    
    if check.returncode:
        print("patch did not apply, saving to {fname}".format(**locals()))
        print("edit {fname} until `cat {fname} | git apply --check` succeeds".format(**locals()))
        print("then run tools/backport_pr.py {num} again".format(**locals()))
        if not os.path.exists(fname):
            with open(fname, 'wb') as f:
                f.write(patch)
        return 1
    
    p = Popen(['git', 'apply'], stdin=PIPE)
    a,b = p.communicate(patch)

    commit = Popen(['git', 'commit', '-a', '-m', msg])
    commit.communicate()
    if commit.returncode:
        print("commit failed!")
        return 1
    else:
        print("PR #%i applied, with msg:" % num)
        print()
        print(msg)
        print()
    
    if branch != current_branch:
        check_call(['git', 'checkout', current_branch])
    
    return 0
コード例 #20
0
ファイル: backport_pr.py プロジェクト: AJRenold/ipython
def should_backport(labels):
    """return set of PRs marked for backport"""
    issues = get_issues_list("ipython/ipython",
            labels=labels,
            state='closed',
            auth=True,
    )
    should_backport = set()
    for issue in issues:
        if not is_pull_request(issue):
            continue
        pr = get_pull_request("ipython/ipython", issue['number'], auth=True)
        if not pr['merged']:
            print ("Marked PR closed without merge: %i" % pr['number'])
            continue
        should_backport.add(pr['number'])
    return should_backport
コード例 #21
0
ファイル: git-mpr.py プロジェクト: guyhf/ipython
def merge_pr(num):
    """ try to merge the branch of PR `num` into current branch
    """
    # Get Github authorisation first, so that the user is prompted straight away
    # if their login is needed.

    pr = gh_api.get_pull_request(gh_project, num)
    repo = pr["head"]["repo"]["clone_url"]

    branch = pr["head"]["ref"]
    mergeable = merge_branch(repo=repo, branch=branch)
    if not mergeable:
        cmd = "git pull " + repo + " " + branch
        not_merged[str(num)] = cmd
        print("==============================================================================")
        print("Something went wrong merging this branch, you can try it manually by runngin :")
        print(cmd)
        print("==============================================================================")
コード例 #22
0
ファイル: backport_pr.py プロジェクト: xuxiandi/ipython
def should_backport(labels):
    """return set of PRs marked for backport"""
    issues = get_issues_list(
        "ipython/ipython",
        labels=labels,
        state='closed',
        auth=True,
    )
    should_backport = set()
    for issue in issues:
        if not is_pull_request(issue):
            continue
        pr = get_pull_request("ipython/ipython", issue['number'], auth=True)
        if not pr['merged']:
            print("Marked PR closed without merge: %i" % pr['number'])
            continue
        should_backport.add(pr['number'])
    return should_backport
コード例 #23
0
ファイル: git-mpr.py プロジェクト: guyhf/ipython
def main(*args):
    parser = argparse.ArgumentParser(
        description="""
                Merge (one|many) github pull request by their number.\
                
                If pull request can't be merge as is, cancel merge,
                and continue to the next if any.
                """
    )
    parser.add_argument("-v2", "--githubapiv2", action="store_const", const=2)

    grp = parser.add_mutually_exclusive_group()
    grp.add_argument(
        "-l", "--list", action="store_const", const=True, help="list PR, their number and their mergeability"
    )
    grp.add_argument(
        "-a", "--merge-all", action="store_const", const=True, help="try to merge as many PR as possible, one by one"
    )
    grp.add_argument("-m", "--merge", type=int, help="The pull request numbers", nargs="*", metavar="pr-number")
    args = parser.parse_args()

    if args.list:
        pr_list = gh_api.get_pulls_list(gh_project)
        for pr in pr_list:
            mergeable = gh_api.get_pull_request(gh_project, pr["number"])["mergeable"]

            ismgb = u"√" if mergeable else " "
            print(u"* #{number} [{ismgb}]:  {title}".format(number=pr["number"], title=pr["title"], ismgb=ismgb))

    if args.merge_all:
        pr_list = gh_api.get_pulls_list(gh_project)
        for pr in pr_list:
            merge_pr(pr["number"])

    elif args.merge:
        for num in args.merge:
            merge_pr(num)

    if not_merged:
        print("*************************************************************************************")
        print("the following branch have not been merged automatically, considere doing it by hand :")
        for num, cmd in not_merged.items():
            print("PR {num}: {cmd}".format(num=num, cmd=cmd))
        print("*************************************************************************************")
コード例 #24
0
def test_pr(num, post_results=True):
    # Get Github authorisation first, so that the user is prompted straight away
    # if their login is needed.
    if post_results:
        gh_api.get_auth_token()

    setup()
    pr = gh_api.get_pull_request(gh_project, num)
    get_branch(
        repo=pr['head']['repo']['clone_url'],
        branch=pr['head']['ref'],
        owner=pr['head']['repo']['owner']['login'],
        mergeable=pr['mergeable'],
    )

    results = []
    for py, venv in venvs:
        tic = time.time()
        passed, log = run_tests(venv)
        elapsed = int(time.time() - tic)
        print("Ran tests with %s in %is" % (py, elapsed))
        missing_libraries = get_missing_libraries(log)
        if passed:
            results.append((py, True, None, missing_libraries))
        else:
            results.append((py, False, log, missing_libraries))

    dump_results(num, results, pr)

    results_paths = save_logs(results, pr)
    print_results(pr, results_paths)

    if post_results:
        results_urls = post_logs(results)
        post_results_comment(pr, results_urls, num)
        print("(Posted to Github)")
    else:
        post_script = os.path.join(os.path.dirname(sys.argv[0]),
                                   "post_pr_test.py")
        print("To post the results to Github, run", post_script)
コード例 #25
0
ファイル: nose_pr.py プロジェクト: npinto/Theano
def test_pr(num, post_results=True):
    # Get Github authorisation first, so that the user is prompted
    # straight away if their login is needed.
    if post_results:
        gh_api.get_auth_token()

    setup()
    pr = gh_api.get_pull_request(gh_project, num)
    get_branch(repo=pr['head']['repo']['clone_url'],
                 branch=pr['head']['ref'],
                 owner=pr['head']['repo']['owner']['login'],
                 mergeable=pr['mergeable'],
              )

    results = []
    for py, venv in venvs:
        tic = time.time()
        passed, log = run_tests(venv)
        elapsed = int(time.time() - tic)
        print("Ran tests with %s in %is" % (py, elapsed))
        missing_libraries = get_missing_libraries(log)
        if passed:
            results.append((py, True, None, missing_libraries))
        else:
            results.append((py, False, log, missing_libraries))

    dump_results(num, results, pr)

    results_paths = save_logs(results, pr)
    print_results(pr, results_paths)

    if post_results:
        results_urls = post_logs(results)
        post_results_comment(pr, results_urls, num)
        print("(Posted to Github)")
    else:
        post_script = os.path.join(os.path.dirname(sys.argv[0]),
             "post_pr_test.py")
        print("To post the results to Github, run", post_script)
コード例 #26
0
def main(*args):
    parser = argparse.ArgumentParser(
            description="""
                Merge (one|many) github pull request by their number.\
                
                If pull request can't be merge as is, cancel merge,
                and continue to the next if any.
                """
            )
    parser.add_argument('-v2', '--githubapiv2', action='store_const', const=2)

    grp = parser.add_mutually_exclusive_group()
    grp.add_argument(
            '-l',
            '--list',
            action='store_const',
            const=True,
            help='list PR, their number and their mergeability')
    grp.add_argument('-a',
            '--merge-all',
            action='store_const',
            const=True ,
            help='try to merge as many PR as possible, one by one')
    grp.add_argument('-m',
            '--merge',
            type=int,
            help="The pull request numbers",
            nargs='*',
            metavar='pr-number')
    args = parser.parse_args()
    if args.githubapiv2 == 2 :
        github_api = 2
    else  :
        github_api = 3

    if(args.list):
        pr_list = gh_api.get_pulls_list(gh_project, github_api)
        for pr in pr_list :
            mergeable = gh_api.get_pull_request(gh_project, pr['number'], github_api=github_api)['mergeable']

            ismgb = u"√" if mergeable else " "
            print(u"* #{number} [{ismgb}]:  {title}".format(
                number=pr['number'],
                title=pr['title'],
                ismgb=ismgb))

    if(args.merge_all):
        pr_list = gh_api.get_pulls_list(gh_project)
        for pr in pr_list :
            merge_pr(pr['number'])


    elif args.merge:
        for num in args.merge :
            merge_pr(num, github_api=github_api)

    if not_merged :
        print('*************************************************************************************')
        print('the following branch have not been merged automatically, considere doing it by hand :')
        for num, cmd in not_merged.items() :
            print( "PR {num}: {cmd}".format(num=num, cmd=cmd))
        print('*************************************************************************************')
コード例 #27
0
def main(*args):
    parser = argparse.ArgumentParser(description="""
                Merge one or more github pull requests by their number. If any
                one pull request can't be merged as is, its merge is ignored
                and the process continues with the next ones (if any).
                """)

    grp = parser.add_mutually_exclusive_group()
    grp.add_argument(
        "-l",
        "--list",
        action="store_const",
        const=True,
        help="list PR, their number and their mergeability",
    )
    grp.add_argument(
        "-a",
        "--merge-all",
        action="store_const",
        const=True,
        help="try to merge as many PR as possible, one by one",
    )
    parser.add_argument(
        "merge",
        type=int,
        help="The pull request numbers",
        nargs="*",
        metavar="pr-number",
    )
    args = parser.parse_args()

    if args.list:
        pr_list = gh_api.get_pulls_list(gh_project)
        for pr in pr_list:
            mergeable = gh_api.get_pull_request(gh_project,
                                                pr["number"])["mergeable"]

            ismgb = u"√" if mergeable else " "
            print(u"* #{number} [{ismgb}]:  {title}".format(
                number=pr["number"], title=pr["title"], ismgb=ismgb))

    if args.merge_all:
        branch_name = "merge-" + "-".join(str(pr["number"]) for pr in pr_list)
        git_new_branch(branch_name)
        pr_list = gh_api.get_pulls_list(gh_project)
        for pr in pr_list:
            merge_pr(pr["number"])

    elif args.merge:
        branch_name = "merge-" + "-".join(map(str, args.merge))
        git_new_branch(branch_name)
        for num in args.merge:
            merge_pr(num)

    if not_merged:
        print(
            "*************************************************************************************"
        )
        print(
            "The following branch has not been merged automatically, consider doing it by hand   :"
        )
        for num, cmd in not_merged.items():
            print("PR {num}: {cmd}".format(num=num, cmd=cmd))
        print(
            "*************************************************************************************"
        )