fix: remove unnecessary question when viewing diffs

This commit is contained in:
Nathaniel Landau
2023-02-05 10:28:53 -05:00
parent 7eb8ff5fa8
commit 401d830942
2 changed files with 3 additions and 13 deletions

View File

@@ -517,13 +517,7 @@ class Application:
alerts.info("No changes to review.") alerts.info("No changes to review.")
return return
print(f"\nFound {len(changed_notes)} changed notes in the vault.\n") alerts.info(f"Found {len(changed_notes)} changed notes in the vault")
answer = self.questions.ask_confirm(
question="View diffs of individual files?", default=False
)
if not answer: # pragma: no cover
return
choices: list[dict[str, Any] | questionary.Separator] = [questionary.Separator()] choices: list[dict[str, Any] | questionary.Separator] = [questionary.Separator()]
for n, note in enumerate(changed_notes, start=1): for n, note in enumerate(changed_notes, start=1):
_selection = { _selection = {
@@ -538,7 +532,7 @@ class Application:
while True: while True:
note_to_review = self.questions.ask_selection( note_to_review = self.questions.ask_selection(
choices=choices, choices=choices,
question="Select a new to view the diff", question="Select an updated note to view the diff",
) )
if note_to_review is None or note_to_review == "return": if note_to_review is None or note_to_review == "return":
break break

View File

@@ -530,10 +530,6 @@ def test_review_changes(test_application, mocker, capsys) -> None:
"obsidian_metadata.models.application.Questions.ask_application_main", "obsidian_metadata.models.application.Questions.ask_application_main",
side_effect=["rename_metadata", "review_changes", KeyError], side_effect=["rename_metadata", "review_changes", KeyError],
) )
mocker.patch(
"obsidian_metadata.models.application.Questions.ask_confirm",
return_value=True,
)
mocker.patch( mocker.patch(
"obsidian_metadata.models.application.Questions.ask_existing_key", "obsidian_metadata.models.application.Questions.ask_existing_key",
return_value="tags", return_value="tags",
@@ -549,7 +545,7 @@ def test_review_changes(test_application, mocker, capsys) -> None:
with pytest.raises(KeyError): with pytest.raises(KeyError):
app.application_main() app.application_main()
captured = capsys.readouterr() captured = capsys.readouterr()
assert captured.out == Regex(r".*Found.*\d+.*changed notes in the vault.*", re.DOTALL) assert captured.out == Regex(r".*Found.*\d+.*changed notes in the vault", re.DOTALL)
assert "- tags:" in captured.out assert "- tags:" in captured.out
assert "+ new_tags:" in captured.out assert "+ new_tags:" in captured.out