From 3cca8dee4477cede613a60233dbea3d6a221f5b2 Mon Sep 17 00:00:00 2001 From: MohammadYusif Date: Thu, 28 May 2026 01:55:23 +0300 Subject: [PATCH] fix: return explicit message when changes() compares identical versions (#2) --- graver/core.py | 3 +++ tests/test_core.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/graver/core.py b/graver/core.py index 9c68980..0e4076b 100644 --- a/graver/core.py +++ b/graver/core.py @@ -84,6 +84,9 @@ def changes(self, v1: str | None = None, v2: str | None = None) -> str: added = [line for line in result["added"] if line.strip()] removed = [line for line in result["removed"] if line.strip()] + if not added and not removed: + return f"No changes between {v1} and {v2}." + lines = [ f"\n{self.name} | {v1} -> {v2}", "=" * 55, diff --git a/tests/test_core.py b/tests/test_core.py index 03ea9e4..82d9742 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -205,3 +205,12 @@ def test_list_all_returns_sorted(tmp_path): Prompt("alpha", base_dir=str(tmp_path)).save("content") names = Prompt.list_all(base_dir=str(tmp_path)) assert names == sorted(names) + + +def test_changes_identical_versions_returns_no_changes_message(tmp_path): + p = Prompt("system", base_dir=str(tmp_path)) + same_content = "You are a helpful assistant." + p.save(same_content) + p.save(same_content) + result = p.changes() + assert result == "No changes between v1 and v2."