15
15
16
16
from . import __version__
17
17
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
-
26
18
CREATE_PR_URL_TEMPLATE = ("https://api.github.com/repos/"
27
19
"{config[team]}/{config[repo]}/pulls" )
28
20
DEFAULT_CONFIG = collections .ChainMap ({
@@ -58,8 +50,16 @@ def __init__(self, pr_remote, commit_sha1, branches,
58
50
* , dry_run = False , push = True ,
59
51
prefix_commit = True ,
60
52
config = DEFAULT_CONFIG ,
53
+ chosen_config_path = None ,
61
54
):
62
55
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
+
63
63
self .config = config
64
64
self .check_repo () # may raise InvalidRepoException
65
65
@@ -80,6 +80,12 @@ def __init__(self, pr_remote, commit_sha1, branches,
80
80
self .push = push
81
81
self .prefix_commit = prefix_commit
82
82
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
+
83
89
@property
84
90
def upstream (self ):
85
91
"""Get the remote name to use for upstream branches
@@ -475,13 +481,13 @@ def cherry_pick_cli(ctx,
475
481
476
482
click .echo ("\U0001F40D \U0001F352 \u26CF " )
477
483
478
- global chosen_config_path
479
484
chosen_config_path , config = load_config (config_path )
480
485
481
486
try :
482
487
cherry_picker = CherryPicker (pr_remote , commit_sha1 , branches ,
483
488
dry_run = dry_run ,
484
- push = push , config = config )
489
+ push = push , config = config ,
490
+ chosen_config_path = chosen_config_path )
485
491
except InvalidRepoException :
486
492
click .echo (f"You're not inside a { config ['repo' ]} repo right now! \U0001F645 " )
487
493
sys .exit (- 1 )
@@ -649,14 +655,6 @@ def get_sha1_from(commitish):
649
655
return subprocess .check_output (cmd ).strip ().decode ('utf-8' )
650
656
651
657
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
-
660
658
def reset_stored_config_ref ():
661
659
"""Remove the config path option from Git config."""
662
660
wipe_cfg_vals_from_git_cfg ('config_path' )
0 commit comments