Skip to content

Commit d1be1da

Browse files
committed
extract input() from ops.prep_debug
1 parent 070a722 commit d1be1da

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

colrev/ops/prep_debug.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,10 @@ def _load_prep_data(self) -> dict:
124124
return prep_data
125125

126126
@colrev.process.operation.Operation.decorate()
127-
def run_debug(self, *, debug_ids: str = "NA") -> None:
127+
def run_debug(self, *, debug_ids: str = "NA", commit_sha: str = "") -> None:
128128
"""Preparation of records (main entrypoint)."""
129129
self.debug_ids = debug_ids.split(",")
130+
self.commit_sha = commit_sha
130131

131132
self.review_manager.logger.info("Start debug prep")
132133
self.review_manager.logger.info(
@@ -135,11 +136,6 @@ def run_debug(self, *, debug_ids: str = "NA") -> None:
135136
"their colrev_origin and correct them."
136137
)
137138

138-
self.polish = input("Polish mode (y/n)?") == "y"
139-
self.commit_sha = input(
140-
"Commit in which the error occurred (press Enter to select the most recent commit):"
141-
)
142-
143139
try:
144140
for i, prep_round in enumerate(
145141
self.review_manager.settings.prep.prep_rounds

colrev/ui_cli/cli.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,13 @@ def load(
726726
type=str,
727727
help="Debug the preparation step for a selected record (can be 'all').",
728728
)
729+
@click.option(
730+
"--commit-sha",
731+
type=str,
732+
default="",
733+
show_default=True,
734+
help="Commit SHA where the error occurred (empty defaults to HEAD).",
735+
)
729736
@click.option(
730737
"--cpu",
731738
type=int,
@@ -761,6 +768,7 @@ def prep(
761768
keep_ids: bool,
762769
polish: bool,
763770
debug: str,
771+
commit_sha: str,
764772
cpu: int,
765773
setup_custom_script: bool,
766774
verbose: bool,
@@ -776,14 +784,23 @@ def prep(
776784
{"verbose_mode": verbose, "force_mode": force, "exact_call": EXACT_CALL},
777785
)
778786

787+
if commit_sha and not debug:
788+
raise click.UsageError(
789+
"--commit-sha can only be used together with --debug"
790+
)
791+
779792
if debug:
780793
review_manager.force_mode = True
781794
debug_prep_operation = review_manager.get_prep_operation(
782795
polish=polish,
783796
cpu=cpu,
784797
debug=True,
785798
)
786-
debug_prep_operation.run_debug(debug_ids=debug) # type: ignore
799+
if not hasattr(debug_prep_operation, "run_debug"):
800+
raise colrev_exceptions.CoLRevException(
801+
"Debug prep operation unavailable."
802+
)
803+
debug_prep_operation.run_debug(debug_ids=debug, commit_sha=commit_sha)
787804
return
788805

789806
prep_operation = review_manager.get_prep_operation(polish=polish, cpu=cpu)

0 commit comments

Comments
 (0)