Show More
@@ -2,8 +2,11 b'' | |||||
2 | # -*- coding: utf-8 -*- |
|
2 | # -*- coding: utf-8 -*- | |
3 | """ |
|
3 | """ | |
4 | Usage: |
|
4 | Usage: | |
5 | python git-mpr.py -m 1657 |
|
5 | git-mpr [-h] [-l | -a] [pr-number [pr-number ...]] | |
|
6 | ||||
|
7 | Type `git mpr -h` for details. | |||
6 | """ |
|
8 | """ | |
|
9 | ||||
7 | from __future__ import print_function |
|
10 | from __future__ import print_function | |
8 |
|
11 | |||
9 | import io, os |
|
12 | import io, os | |
@@ -31,7 +34,13 b' def merge_branch(repo, branch ):' | |||||
31 | return False |
|
34 | return False | |
32 | return True |
|
35 | return True | |
33 |
|
36 | |||
|
37 | ||||
|
38 | def git_new_branch(name): | |||
|
39 | """Create a new branch with the given name and check it out. | |||
|
40 | """ | |||
|
41 | check_call(['git', 'checkout', '-b', name]) | |||
34 |
|
42 | |||
|
43 | ||||
35 | def merge_pr(num): |
|
44 | def merge_pr(num): | |
36 | """ try to merge the branch of PR `num` into current branch |
|
45 | """ try to merge the branch of PR `num` into current branch | |
37 | """ |
|
46 | """ | |
@@ -95,12 +104,16 b' def main(*args):' | |||||
95 | ismgb=ismgb)) |
|
104 | ismgb=ismgb)) | |
96 |
|
105 | |||
97 | if(args.merge_all): |
|
106 | if(args.merge_all): | |
|
107 | branch_name = 'merge-' + '-'.join(str(pr['number']) for pr in pr_list) | |||
|
108 | git_new_branch(branch_name) | |||
98 | pr_list = gh_api.get_pulls_list(gh_project) |
|
109 | pr_list = gh_api.get_pulls_list(gh_project) | |
99 | for pr in pr_list : |
|
110 | for pr in pr_list : | |
100 | merge_pr(pr['number']) |
|
111 | merge_pr(pr['number']) | |
101 |
|
112 | |||
102 |
|
113 | |||
103 | elif args.merge: |
|
114 | elif args.merge: | |
|
115 | branch_name = 'merge-' + '-'.join(map(str, args.merge)) | |||
|
116 | git_new_branch(branch_name) | |||
104 | for num in args.merge : |
|
117 | for num in args.merge : | |
105 | merge_pr(num) |
|
118 | merge_pr(num) | |
106 |
|
119 |
General Comments 0
You need to be logged in to leave comments.
Login now