mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
Merge 1340c4c2e8 into 4fade39c90
This commit is contained in:
commit
12ba9cca29
2 changed files with 30 additions and 1 deletions
|
|
@ -4920,7 +4920,12 @@ def _restore_stashed_changes(
|
|||
if input_fn is not None:
|
||||
response = input_fn("Restore local changes now? [Y/n]", "y")
|
||||
else:
|
||||
response = input().strip().lower()
|
||||
try:
|
||||
response = input().strip().lower()
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
print()
|
||||
print("No interactive input available — skipping automatic restore.")
|
||||
response = "n"
|
||||
if response not in ("", "y", "yes"):
|
||||
print("Skipped restoring local changes.")
|
||||
print("Your changes are still preserved in git stash.")
|
||||
|
|
|
|||
|
|
@ -116,6 +116,30 @@ def test_restore_stashed_changes_can_skip_restore_and_keep_stash(monkeypatch, tm
|
|||
assert "git stash apply abc123" in out
|
||||
|
||||
|
||||
def test_restore_stashed_changes_handles_eof_and_keeps_stash(monkeypatch, tmp_path, capsys):
|
||||
calls = []
|
||||
|
||||
def fake_run(cmd, **kwargs):
|
||||
calls.append((cmd, kwargs))
|
||||
raise AssertionError(f"unexpected command: {cmd}")
|
||||
|
||||
monkeypatch.setattr(hermes_main.subprocess, "run", fake_run)
|
||||
|
||||
def _raise_eof():
|
||||
raise EOFError
|
||||
|
||||
monkeypatch.setattr("builtins.input", _raise_eof)
|
||||
|
||||
restored = hermes_main._restore_stashed_changes(["git"], tmp_path, "abc123", prompt_user=True)
|
||||
|
||||
assert restored is False
|
||||
assert calls == []
|
||||
out = capsys.readouterr().out
|
||||
assert "No interactive input available — skipping automatic restore." in out
|
||||
assert "Your changes are still preserved in git stash." in out
|
||||
assert "git stash apply abc123" in out
|
||||
|
||||
|
||||
def test_restore_stashed_changes_applies_without_prompt_when_disabled(monkeypatch, tmp_path, capsys):
|
||||
calls = []
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue