@@ -1359,41 +1359,55 @@ def new_pr(paths, ecs, title=None, descr=None, commit_msg=None):
13591359 _log .info ("Failed to add labels to PR# %s: %s." % (pr , err ))
13601360
13611361
1362+ def det_account_branch_for_pr (pr_id , github_user = None ):
1363+ """Determine account & branch corresponding to pull request with specified id."""
1364+
1365+ if github_user is None :
1366+ github_user = build_option ('github_user' )
1367+
1368+ if github_user is None :
1369+ raise EasyBuildError ("GitHub username (--github-user) must be specified!" )
1370+
1371+ pr_target_account = build_option ('pr_target_account' )
1372+ pr_target_repo = build_option ('pr_target_repo' )
1373+
1374+ pr_data , _ = fetch_pr_data (pr_id , pr_target_account , pr_target_repo , github_user )
1375+
1376+ # branch that corresponds with PR is supplied in form <account>:<branch_label>
1377+ account = pr_data ['head' ]['label' ].split (':' )[0 ]
1378+ branch = ':' .join (pr_data ['head' ]['label' ].split (':' )[1 :])
1379+ github_target = '%s/%s' % (pr_target_account , pr_target_repo )
1380+ print_msg ("Determined branch name corresponding to %s PR #%s: %s" % (github_target , pr_id , branch ), log = _log )
1381+
1382+ return account , branch
1383+
1384+
13621385@only_if_module_is_available ('git' , pkgname = 'GitPython' )
1363- def update_pr (pr , paths , ecs , commit_msg = None ):
1386+ def update_pr (pr_id , paths , ecs , commit_msg = None ):
13641387 """
13651388 Update specified pull request using specified files
13661389
1367- :param pr : ID of pull request to update
1390+ :param pr_id : ID of pull request to update
13681391 :param paths: paths to categorized lists of files (easyconfigs, files to delete, patches)
13691392 :param ecs: list of parsed easyconfigs, incl. for dependencies (if robot is enabled)
13701393 :param commit_msg: commit message to use
13711394 """
1372- github_user = build_option ('github_user' )
1373- if github_user is None :
1374- raise EasyBuildError ("GitHub user must be specified to use --update-pr" )
13751395
13761396 if commit_msg is None :
13771397 raise EasyBuildError ("A meaningful commit message must be specified via --pr-commit-msg when using --update-pr" )
13781398
13791399 pr_target_account = build_option ('pr_target_account' )
13801400 pr_target_repo = build_option ('pr_target_repo' )
13811401
1382- pr_data , _ = fetch_pr_data (pr , pr_target_account , pr_target_repo , github_user )
1383-
1384- # branch that corresponds with PR is supplied in form <account>:<branch_label>
1385- account = pr_data ['head' ]['label' ].split (':' )[0 ]
1386- branch = ':' .join (pr_data ['head' ]['label' ].split (':' )[1 :])
1387- github_target = '%s/%s' % (pr_target_account , pr_target_repo )
1388- print_msg ("Determined branch name corresponding to %s PR #%s: %s" % (github_target , pr , branch ), log = _log )
1402+ account , branch = det_account_branch_for_pr (pr_id )
13891403
13901404 _ , _ , _ , _ , diff_stat = _easyconfigs_pr_common (paths , ecs , start_branch = branch , pr_branch = branch ,
13911405 start_account = account , commit_msg = commit_msg )
13921406
13931407 print_msg ("Overview of changes:\n %s\n " % diff_stat , log = _log , prefix = False )
13941408
13951409 full_repo = '%s/%s' % (pr_target_account , pr_target_repo )
1396- msg = "Updated %s PR #%s by pushing to branch %s/%s" % (full_repo , pr , account , branch )
1410+ msg = "Updated %s PR #%s by pushing to branch %s/%s" % (full_repo , pr_id , account , branch )
13971411 if build_option ('dry_run' ) or build_option ('extended_dry_run' ):
13981412 msg += " [DRY RUN]"
13991413 print_msg (msg , log = _log , prefix = False )
0 commit comments