Show More
@@ -2,11 +2,11 | |||
|
2 | 2 | """ |
|
3 | 3 | Backport pull requests to a particular branch. |
|
4 | 4 | |
|
5 | Usage: backport_pr.py branch [PR] | |
|
5 | Usage: backport_pr.py branch [PR] [PR2] | |
|
6 | 6 | |
|
7 | 7 | e.g.: |
|
8 | 8 | |
|
9 | python tools/backport_pr.py 0.13.1 123 | |
|
9 | python tools/backport_pr.py 0.13.1 123 155 | |
|
10 | 10 | |
|
11 | 11 | to backport PR #123 onto branch 0.13.1 |
|
12 | 12 | |
@@ -70,6 +70,11 def backport_pr(branch, num, project='ipython/ipython'): | |||
|
70 | 70 | req = urlopen(patch_url) |
|
71 | 71 | patch = req.read() |
|
72 | 72 | |
|
73 | lines = description.splitlines() | |
|
74 | if len(lines) > 5: | |
|
75 | lines = lines[:5] + ['...'] | |
|
76 | description = '\n'.join(lines) | |
|
77 | ||
|
73 | 78 | msg = "Backport PR #%i: %s" % (num, title) + '\n\n' + description |
|
74 | 79 | check = Popen(['git', 'apply', '--check', '--verbose'], stdin=PIPE) |
|
75 | 80 | a,b = check.communicate(patch) |
@@ -142,6 +147,8 def should_backport(labels=None, milestone=None): | |||
|
142 | 147 | if not pr['merged']: |
|
143 | 148 | print ("Marked PR closed without merge: %i" % pr['number']) |
|
144 | 149 | continue |
|
150 | if pr['base']['ref'] != 'master': | |
|
151 | continue | |
|
145 | 152 | should_backport.add(pr['number']) |
|
146 | 153 | return should_backport |
|
147 | 154 | |
@@ -161,4 +168,9 if __name__ == '__main__': | |||
|
161 | 168 | print (pr) |
|
162 | 169 | sys.exit(0) |
|
163 | 170 | |
|
164 | sys.exit(backport_pr(sys.argv[1], int(sys.argv[2]))) | |
|
171 | for prno in map(int, sys.argv[2:]): | |
|
172 | print("Backporting PR #%i" % prno) | |
|
173 | rc = backport_pr(sys.argv[1], prno) | |
|
174 | if rc: | |
|
175 | print("Backporting PR #%i failed" % prno) | |
|
176 | sys.exit(rc) |
General Comments 0
You need to be logged in to leave comments.
Login now