Skip to content

Commit e4f927d

Browse files
authored
When raising error, show the current state vs expected state (#87)
1 parent e4ece75 commit e4f927d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cherry_picker/cherry_picker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,9 @@ def abort_cherry_pick(self):
541541
run `git cherry-pick --abort` and then clean up the branch
542542
"""
543543
if self.initial_state != WORKFLOW_STATES.BACKPORT_PAUSED:
544-
raise ValueError("One can only abort a paused process.")
544+
raise ValueError(
545+
f"One can only abort a paused process. Current state: {self.initial_state}. Expected state: {WORKFLOW_STATES.BACKPORT_PAUSED}"
546+
)
545547

546548
try:
547549
validate_sha("CHERRY_PICK_HEAD")

cherry_picker/test_cherry_picker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import pathlib
3+
import re
34
import subprocess
45
import warnings
56
from collections import ChainMap
@@ -1141,7 +1142,7 @@ def test_continue_cherry_pick_invalid_state(tmp_git_repo_dir):
11411142

11421143
assert get_state() == WORKFLOW_STATES.UNSET
11431144

1144-
with pytest.raises(ValueError, match=r"^One can only continue a paused process.$"):
1145+
with pytest.raises(ValueError, match=re.compile(r"^One can only continue a paused process.")):
11451146
cherry_picker.continue_cherry_pick()
11461147

11471148
assert get_state() == WORKFLOW_STATES.UNSET # success
@@ -1167,7 +1168,7 @@ def test_abort_cherry_pick_invalid_state(tmp_git_repo_dir):
11671168

11681169
assert get_state() == WORKFLOW_STATES.UNSET
11691170

1170-
with pytest.raises(ValueError, match=r"^One can only abort a paused process.$"):
1171+
with pytest.raises(ValueError, match=re.compile(r"^One can only abort a paused process.")):
11711172
cherry_picker.abort_cherry_pick()
11721173

11731174

0 commit comments

Comments
 (0)