##// END OF EJS Templates
Add repo support
Jonathan Frederic -
Show More
@@ -2,20 +2,27 b''
2 """
2 """
3 Backport pull requests to a particular branch.
3 Backport pull requests to a particular branch.
4
4
5 Usage: backport_pr.py branch [PR] [PR2]
5 Usage: backport_pr.py [org/repository] branch [PR] [PR2]
6
6
7 e.g.:
7 e.g.:
8
8
9 python tools/backport_pr.py 0.13.1 123 155
9 python tools/backport_pr.py 0.13.1 123 155
10
10
11 to backport PR #123 onto branch 0.13.1
11 to backport PRs #123 and #155 onto branch 0.13.1
12
12
13 or
13 or
14
14
15 python tools/backport_pr.py 2.1
15 python tools/backport_pr.py 2.1
16
16
17 to see what PRs are marked for backport with milestone=2.1 that have yet to be applied
17 to see what PRs are marked for backport with milestone=2.1 that have yet to be applied
18 to branch 2.x.
18 to branch 2.x
19
20 or
21
22 python tools/backport_pr.py jupyter/notebook 0.13.1 123 155
23
24 to backport PRs #123 and #155 of the `jupyter/notebook` repo onto branch 0.13.1
25 of that repo.
19
26
20 """
27 """
21
28
@@ -153,24 +160,30 b" def should_backport(labels=None, milestone=None, project='ipython/ipython'):"
153 return should_backport
160 return should_backport
154
161
155 if __name__ == '__main__':
162 if __name__ == '__main__':
156
163 project = 'ipython/ipython'
157 if len(sys.argv) < 2:
164 args = list(sys.argv)
165 if len(args) >= 2:
166 if '/' in args[1]:
167 project = args[1]
168 del args[1]
169
170 if len(args) < 2:
158 print(__doc__)
171 print(__doc__)
159 sys.exit(1)
172 sys.exit(1)
160
173
161 if len(sys.argv) < 3:
174 if len(args) < 3:
162 milestone = sys.argv[1]
175 milestone = args[1]
163 branch = milestone.split('.')[0] + '.x'
176 branch = milestone.split('.')[0] + '.x'
164 already = already_backported(branch)
177 already = already_backported(branch)
165 should = should_backport(milestone=milestone)
178 should = should_backport(milestone=milestone, project=project)
166 print ("The following PRs should be backported:")
179 print ("The following PRs should be backported:")
167 for pr in sorted(should.difference(already)):
180 for pr in sorted(should.difference(already)):
168 print (pr)
181 print (pr)
169 sys.exit(0)
182 sys.exit(0)
170
183
171 for prno in map(int, sys.argv[2:]):
184 for prno in map(int, args[2:]):
172 print("Backporting PR #%i" % prno)
185 print("Backporting PR #%i" % prno)
173 rc = backport_pr(sys.argv[1], prno)
186 rc = backport_pr(args[1], prno, project=project)
174 if rc:
187 if rc:
175 print("Backporting PR #%i failed" % prno)
188 print("Backporting PR #%i failed" % prno)
176 sys.exit(rc)
189 sys.exit(rc)
General Comments 0
You need to be logged in to leave comments. Login now