Skip to content

Commit e6280d3

Browse files
committed
fix: return explicit message when changes() compares identical versions (#2)
1 parent 0abbae0 commit e6280d3

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

graver/core.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ def changes(self, v1: str | None = None, v2: str | None = None) -> str:
8484
added = [line for line in result["added"] if line.strip()]
8585
removed = [line for line in result["removed"] if line.strip()]
8686

87+
if not added and not removed:
88+
return f"No changes between {v1} and {v2}."
89+
8790
lines = [
8891
f"\n{self.name} | {v1} -> {v2}",
8992
"=" * 55,

tests/test_core.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,12 @@ def test_list_all_returns_sorted(tmp_path):
205205
Prompt("alpha", base_dir=str(tmp_path)).save("content")
206206
names = Prompt.list_all(base_dir=str(tmp_path))
207207
assert names == sorted(names)
208+
209+
210+
def test_changes_identical_versions_returns_no_changes_message(tmp_path):
211+
p = Prompt("system", base_dir=str(tmp_path))
212+
same_content = "You are a helpful assistant."
213+
p.save(same_content)
214+
p.save(same_content)
215+
result = p.changes()
216+
assert result == "No changes between v1 and v2."

0 commit comments

Comments
 (0)