Пример #1
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(
            '*************************************************************************************'
        )
Пример #2
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('*************************************************************************************')
Пример #3
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.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("*************************************************************************************")
Пример #4
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('*************************************************************************************')
Пример #5
0
if __name__ == "__main__":

    if len(sys.argv) != 2:
        print(__doc__)
        sys.exit(1)

    milestone = sys.argv[1]

    milestone_id = get_milestone_id("jupyter/nbgrader", milestone)

    issues = get_issues_list("jupyter/nbgrader",
                             state='all',
                             milestone=milestone_id)

    pulls = get_pulls_list("jupyter/nbgrader",
                           state='merged',
                           milestone=milestone_id)

    users = set()
    for issue in issues:
        users.add(issue['user']['login'])
    for pull in pulls:
        users.add(pull['user']['login'])

    users = {user.lower(): user for user in users}
    print()
    print("The following users have submitted issues and/or PRs:")
    print("-----------------------------------------------------")
    for user in sorted(users.keys()):
        print(users[user])
    print("-----------------------------------------------------")
        print(__doc__)
        sys.exit(1)

    milestone = sys.argv[1]

    milestone_id = get_milestone_id(
        "jupyter/nbgrader",
        milestone)

    issues = get_issues_list(
        "jupyter/nbgrader",
        state='all',
        milestone=milestone_id)

    pulls = get_pulls_list(
        "jupyter/nbgrader",
        state='merged',
        milestone=milestone_id)

    users = set()
    for issue in issues:
        users.add(issue['user']['login'])
    for pull in pulls:
        users.add(pull['user']['login'])

    users = {user.lower(): user for user in users}
    print()
    print("The following users have submitted issues and/or PRs:")
    print("-----------------------------------------------------")
    for user in sorted(users.keys()):
        print(users[user])
    print("-----------------------------------------------------")
Пример #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
import sys
from gh_api import (
    get_milestone_id,
    get_pulls_list
)

if __name__ == "__main__":

    if len(sys.argv) != 2:
        print(__doc__)
        sys.exit(1)

    milestone = sys.argv[1]

    all_pulls = get_pulls_list(
        "jupyter/nbgrader",
        state='closed',
        auth=True)

    pulls = []
    for pr in all_pulls:
        if pr['milestone']['title'] == milestone and pr['merged_at']:
            pulls.append(pr)

    print()
    print("The following PRs were merged for the {} milestone:".format(milestone))
    print("-----------------------------------------------------")
    for pull in pulls:
        print("- PR #{}: {}".format(pull['number'], pull['title']))
    print("-----------------------------------------------------")