Skip to content

Commit

Permalink
Remove initial_state as it gets out of sync with what's in .git/config
Browse files Browse the repository at this point in the history
  • Loading branch information
ambv committed Oct 11, 2023
1 parent e4f927d commit f2f00cd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cherry_picker/cherry_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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-"):
Expand Down

0 comments on commit f2f00cd

Please sign in to comment.