Skip to content

Commit 926d5a1

Browse files
committed
BUG: Hide changelog diff from sync preview
1 parent 49c7e57 commit 926d5a1

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/fmu_settings_cli/sync/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ def sync(
105105
raise typer.Exit(0)
106106

107107
for resource, change_list in changes.items():
108+
if resource == "_changelog":
109+
continue
108110
display_model_diff(resource, change_list)
109111

110112
from_dir_abs = from_dir.absolute()

tests/test_sync/test_sync_cli.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def test_sync_finds_changed_value_field(
153153
app, ["sync", "--to", str(project_b.path.parent)], input="n\n"
154154
)
155155
assert "Value Changes in config" in result.stdout
156+
assert "_changelog" not in result.stdout
156157
assert "model.name" in result.stdout
157158
assert "foo" in result.stdout
158159
assert result.exit_code == 1
@@ -178,6 +179,7 @@ def test_sync_finds_changed_value_field_and_saves_after_confirm(
178179
app, ["sync", "--to", str(project_b.path.parent)], input="y\n"
179180
)
180181
assert "Value Changes in config" in result.stdout
182+
assert "_changelog" not in result.stdout
181183
assert "model.name" in result.stdout
182184
assert "foo" in result.stdout
183185
assert "Success: All done!" in result.stdout
@@ -189,6 +191,32 @@ def test_sync_finds_changed_value_field_and_saves_after_confirm(
189191
assert project_b.config.load(force=True).model.name == "foo" # type: ignore[union-attr]
190192

191193

194+
def test_sync_changelog_only_is_merged_without_being_displayed(
195+
two_fmu_revisions: tuple[Path, ProjectFMUDirectory, ProjectFMUDirectory],
196+
monkeypatch: MonkeyPatch,
197+
) -> None:
198+
"""Tests that changelog-only differences are synced but not rendered."""
199+
tmp_path, project_a, project_b = two_fmu_revisions
200+
monkeypatch.chdir(project_a.path.parent)
201+
202+
target_changelog_size = len(project_b.changelog.load())
203+
project_a.changelog.log_copy_revision_to_changelog(project_a.base_path)
204+
205+
result = runner.invoke(
206+
app, ["sync", "--to", str(project_b.path.parent)], input="y\n"
207+
)
208+
209+
assert "Value Changes in _changelog" not in result.stdout
210+
assert "Complex Changes in _changelog" not in result.stdout
211+
assert "Success: All done!" in result.stdout
212+
assert result.exit_code == 0
213+
214+
target_changelog = project_b.changelog.load(force=True)
215+
assert len(target_changelog) == target_changelog_size + 2
216+
assert target_changelog[-2].change_type == "copy"
217+
assert target_changelog[-2].path == project_a.base_path
218+
219+
192220
def test_sync_finds_changed_complex_field_and_saves_after_confirm(
193221
two_fmu_revisions: tuple[Path, ProjectFMUDirectory, ProjectFMUDirectory],
194222
monkeypatch: MonkeyPatch,

0 commit comments

Comments
 (0)