@@ -119,7 +119,6 @@ def __init__(
119
119
self .config = config
120
120
self .check_repo () # may raise InvalidRepoException
121
121
122
- self .initial_state = self .get_state_and_verify ()
123
122
"""The runtime state loaded from the config.
124
123
125
124
Used to verify that we resume the process from the valid
@@ -540,9 +539,10 @@ def abort_cherry_pick(self):
540
539
"""
541
540
run `git cherry-pick --abort` and then clean up the branch
542
541
"""
543
- if self .initial_state != WORKFLOW_STATES .BACKPORT_PAUSED :
542
+ state = self .get_state_and_verify ()
543
+ if state != WORKFLOW_STATES .BACKPORT_PAUSED :
544
544
raise ValueError (
545
- f"One can only abort a paused process. Current state: { self . initial_state } . Expected state: { WORKFLOW_STATES .BACKPORT_PAUSED } "
545
+ f"One can only abort a paused process. Current state: { state } . Expected state: { WORKFLOW_STATES .BACKPORT_PAUSED } "
546
546
)
547
547
548
548
try :
@@ -572,8 +572,11 @@ def continue_cherry_pick(self):
572
572
open the PR
573
573
clean up branch
574
574
"""
575
- if self .initial_state != WORKFLOW_STATES .BACKPORT_PAUSED :
576
- raise ValueError ("One can only continue a paused process." )
575
+ state = self .get_state_and_verify ()
576
+ if state != WORKFLOW_STATES .BACKPORT_PAUSED :
577
+ raise ValueError (
578
+ f"One can only continue a paused process. Current state: { state } . Expected state: { WORKFLOW_STATES .BACKPORT_PAUSED } "
579
+ )
577
580
578
581
cherry_pick_branch = get_current_branch ()
579
582
if cherry_pick_branch .startswith ("backport-" ):
@@ -637,8 +640,9 @@ def check_repo(self):
637
640
"""
638
641
try :
639
642
validate_sha (self .config ["check_sha" ])
640
- except ValueError :
641
- raise InvalidRepoException ()
643
+ self .get_state_and_verify ()
644
+ except ValueError as ve :
645
+ raise InvalidRepoException (ve .args [0 ])
642
646
643
647
def get_state_and_verify (self ):
644
648
"""Return the run progress state stored in the Git config.
0 commit comments