@@ -99,6 +99,14 @@ def continue_maybe(prompt):
99
99
fail ("Okay, exiting" )
100
100
101
101
102
+ def continue_maybe2 (prompt ):
103
+ result = input ("\n %s (y/n): " % prompt )
104
+ if result .lower () != "y" :
105
+ return False
106
+ else :
107
+ return True
108
+
109
+
102
110
original_head = run_cmd ("git rev-parse HEAD" )[:8 ]
103
111
104
112
@@ -193,6 +201,40 @@ def merge_pr(pr_num, target_ref):
193
201
return merge_hash
194
202
195
203
204
+ def update_pr (pr_num , user_login , base_ref ):
205
+
206
+ pr_branch_name = "%s_MERGE_PR_%s" % (BRANCH_PREFIX , pr_num )
207
+
208
+ run_cmd ("git fetch %s pull/%s/head:%s" % (PR_REMOTE_NAME , pr_num ,
209
+ pr_branch_name ))
210
+ run_cmd ("git checkout %s" % pr_branch_name )
211
+
212
+ continue_maybe ("Update ready (local ref %s)? Push to %s/%s?" % (
213
+ pr_branch_name , user_login , base_ref ))
214
+
215
+ push_user_remote = "https://github.com/%s/pandas.git" % user_login
216
+
217
+ try :
218
+ run_cmd ('git push %s %s:%s' % (push_user_remote , pr_branch_name ,
219
+ base_ref ))
220
+ except Exception as e :
221
+
222
+ if continue_maybe2 ("Force push?" ):
223
+ try :
224
+ run_cmd (
225
+ 'git push -f %s %s:%s' % (push_user_remote , pr_branch_name ,
226
+ base_ref ))
227
+ except Exception as e :
228
+ fail ("Exception while pushing: %s" % e )
229
+ clean_up ()
230
+ else :
231
+ fail ("Exception while pushing: %s" % e )
232
+ clean_up ()
233
+
234
+ clean_up ()
235
+ print ("Pull request #%s updated!" % pr_num )
236
+
237
+
196
238
def cherry_pick (pr_num , merge_hash , default_branch ):
197
239
pick_ref = input ("Enter a branch name [%s]: " % default_branch )
198
240
if pick_ref == "" :
@@ -257,8 +299,17 @@ def fix_version_from_branch(branch, versions):
257
299
print ("\n === Pull Request #%s ===" % pr_num )
258
300
print ("title\t %s\n source\t %s\n target\t %s\n url\t %s"
259
301
% (title , pr_repo_desc , target_ref , url ))
260
- continue_maybe ("Proceed with merging pull request #%s?" % pr_num )
302
+
303
+
261
304
262
305
merged_refs = [target_ref ]
263
306
264
- merge_hash = merge_pr (pr_num , target_ref )
307
+ print ("\n Proceed with updating or merging pull request #%s?" % pr_num )
308
+ update = input ("Update PR and push to remote (r), merge locally (l), "
309
+ "or do nothing (n) ?" )
310
+ update = update .lower ()
311
+
312
+ if update == 'r' :
313
+ merge_hash = update_pr (pr_num , user_login , base_ref )
314
+ elif update == 'l' :
315
+ merge_hash = merge_pr (pr_num , target_ref )
0 commit comments