MCPcopy Create free account
hub / github.com/ipython/ipython / main

Function main

tools/git-mpr.py:66–124  ·  view source on GitHub ↗
(*args)

Source from the content-addressed store, hash-verified

64
65
66def main(*args):
67 parser = argparse.ArgumentParser(
68 description="""
69 Merge one or more github pull requests by their number. If any
70 one pull request can't be merged as is, its merge is ignored
71 and the process continues with the next ones (if any).
72 """
73 )
74
75 grp = parser.add_mutually_exclusive_group()
76 grp.add_argument(
77 '-l',
78 '--list',
79 action='store_const',
80 const=True,
81 help='list PR, their number and their mergeability')
82 grp.add_argument('-a',
83 '--merge-all',
84 action='store_const',
85 const=True ,
86 help='try to merge as many PR as possible, one by one')
87 parser.add_argument('merge',
88 type=int,
89 help="The pull request numbers",
90 nargs='*',
91 metavar='pr-number')
92 args = parser.parse_args()
93
94 if(args.list):
95 pr_list = gh_api.get_pulls_list(gh_project)
96 for pr in pr_list :
97 mergeable = gh_api.get_pull_request(gh_project, pr['number'])['mergeable']
98
99 ismgb = u"√" if mergeable else " "
100 print(u"* #{number} [{ismgb}]: {title}".format(
101 number=pr['number'],
102 title=pr['title'],
103 ismgb=ismgb))
104
105 if(args.merge_all):
106 branch_name = 'merge-' + '-'.join(str(pr['number']) for pr in pr_list)
107 git_new_branch(branch_name)
108 pr_list = gh_api.get_pulls_list(gh_project)
109 for pr in pr_list :
110 merge_pr(pr['number'])
111
112
113 elif args.merge:
114 branch_name = 'merge-' + '-'.join(map(str, args.merge))
115 git_new_branch(branch_name)
116 for num in args.merge :
117 merge_pr(num)
118
119 if not_merged :
120 print('*************************************************************************************')
121 print('The following branch has not been merged automatically, consider doing it by hand :')
122 for num, cmd in not_merged.items() :
123 print( "PR {num}: {cmd}".format(num=num, cmd=cmd))

Callers 1

git-mpr.pyFile · 0.70

Calls 3

git_new_branchFunction · 0.85
merge_prFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected