1515
1616from . import __version__
1717
18-
19- chosen_config_path = None
20- """The config reference used in the current runtime.
21-
22- It starts with a Git revision specifier, followed by a colon
23- and a path relative to the repo root.
24- """
25-
2618CREATE_PR_URL_TEMPLATE = ("https://api.github.com/repos/"
2719 "{config[team]}/{config[repo]}/pulls" )
2820DEFAULT_CONFIG = collections .ChainMap ({
@@ -58,8 +50,16 @@ def __init__(self, pr_remote, commit_sha1, branches,
5850 * , dry_run = False , push = True ,
5951 prefix_commit = True ,
6052 config = DEFAULT_CONFIG ,
53+ chosen_config_path = None ,
6154 ):
6255
56+ self .chosen_config_path = chosen_config_path
57+ """The config reference used in the current runtime.
58+
59+ It starts with a Git revision specifier, followed by a colon
60+ and a path relative to the repo root.
61+ """
62+
6363 self .config = config
6464 self .check_repo () # may raise InvalidRepoException
6565
@@ -80,6 +80,12 @@ def __init__(self, pr_remote, commit_sha1, branches,
8080 self .push = push
8181 self .prefix_commit = prefix_commit
8282
83+ def set_paused_state ():
84+ """Save paused progress state into Git config."""
85+ if self .chosen_config_path is not None :
86+ save_cfg_vals_to_git_cfg (config_path = self .chosen_config_path )
87+ set_state ('BACKPORT_PAUSED' )
88+
8389 @property
8490 def upstream (self ):
8591 """Get the remote name to use for upstream branches
@@ -475,13 +481,13 @@ def cherry_pick_cli(ctx,
475481
476482 click .echo ("\U0001F40D \U0001F352 \u26CF " )
477483
478- global chosen_config_path
479484 chosen_config_path , config = load_config (config_path )
480485
481486 try :
482487 cherry_picker = CherryPicker (pr_remote , commit_sha1 , branches ,
483488 dry_run = dry_run ,
484- push = push , config = config )
489+ push = push , config = config ,
490+ chosen_config_path = chosen_config_path )
485491 except InvalidRepoException :
486492 click .echo (f"You're not inside a { config ['repo' ]} repo right now! \U0001F645 " )
487493 sys .exit (- 1 )
@@ -649,14 +655,6 @@ def get_sha1_from(commitish):
649655 return subprocess .check_output (cmd ).strip ().decode ('utf-8' )
650656
651657
652- def set_paused_state ():
653- """Save paused progress state into Git config."""
654- global chosen_config_path
655- if chosen_config_path is not None :
656- save_cfg_vals_to_git_cfg (config_path = chosen_config_path )
657- set_state ('BACKPORT_PAUSED' )
658-
659-
660658def reset_stored_config_ref ():
661659 """Remove the config path option from Git config."""
662660 wipe_cfg_vals_from_git_cfg ('config_path' )
0 commit comments