From f2f00cd96e6ae75bcf2efb5215bd62bfe721c4bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Langa?= Date: Wed, 11 Oct 2023 11:22:17 +0200 Subject: [PATCH] Remove `initial_state` as it gets out of sync with what's in .git/config --- cherry_picker/cherry_picker.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cherry_picker/cherry_picker.py b/cherry_picker/cherry_picker.py index ec5ddc4..3f234ec 100755 --- a/cherry_picker/cherry_picker.py +++ b/cherry_picker/cherry_picker.py @@ -119,7 +119,6 @@ def __init__( self.config = config self.check_repo() # may raise InvalidRepoException - self.initial_state = self.get_state_and_verify() """The runtime state loaded from the config. Used to verify that we resume the process from the valid @@ -540,9 +539,10 @@ def abort_cherry_pick(self): """ run `git cherry-pick --abort` and then clean up the branch """ - if self.initial_state != WORKFLOW_STATES.BACKPORT_PAUSED: + state = self.get_state_and_verify() + if state != WORKFLOW_STATES.BACKPORT_PAUSED: raise ValueError( - f"One can only abort a paused process. Current state: {self.initial_state}. Expected state: {WORKFLOW_STATES.BACKPORT_PAUSED}" + f"One can only abort a paused process. Current state: {state}. Expected state: {WORKFLOW_STATES.BACKPORT_PAUSED}" ) try: @@ -572,8 +572,11 @@ def continue_cherry_pick(self): open the PR clean up branch """ - if self.initial_state != WORKFLOW_STATES.BACKPORT_PAUSED: - raise ValueError("One can only continue a paused process.") + state = self.get_state_and_verify() + if state != WORKFLOW_STATES.BACKPORT_PAUSED: + raise ValueError( + f"One can only continue a paused process. Current state: {state}. Expected state: {WORKFLOW_STATES.BACKPORT_PAUSED}" + ) cherry_pick_branch = get_current_branch() if cherry_pick_branch.startswith("backport-"):