Skip to content

Commit 04c0ad0

Browse files
committed
fix: only count update as successful when post_update passes
1 parent 7149d7f commit 04c0ad0

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/mcpm/commands/update.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,16 +312,19 @@ def _run_update(
312312
continue
313313

314314
console.print(f" git pull [green]✓[/] ({status.commits_behind} new commit{'s' if status.commits_behind != 1 else ''})")
315-
sources.mark_updated(name)
316315

317316
# Post-update command
317+
post_ok = True
318318
if source.post_update:
319-
post_success = _run_post_update(source.post_update, repo_path)
320-
if not post_success:
319+
post_ok = _run_post_update(source.post_update, repo_path)
320+
if not post_ok:
321321
console.print(f" [dim]Run manually: cd {source.path} && {source.post_update}[/]")
322322

323+
if post_ok:
324+
sources.mark_updated(name)
325+
success_count += 1
326+
323327
console.print()
324-
success_count += 1
325328

326329
console.print(f"[bold green]Done.[/] {success_count} server(s) updated.")
327330

tests/test_update.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def test_apply_with_post_update_success(self, monkeypatch, tmp_path):
421421
assert "1 server(s) updated" in result.output
422422

423423
def test_apply_with_post_update_failure(self, monkeypatch, tmp_path):
424-
"""Test that post_update failure is reported but pull still counted."""
424+
"""Test that post_update failure prevents counting as successful update."""
425425
sources_path = tmp_path / "sources.json"
426426
repo_dir = tmp_path / "repo"
427427
repo_dir.mkdir()
@@ -448,8 +448,8 @@ def test_apply_with_post_update_failure(self, monkeypatch, tmp_path):
448448

449449
runner = CliRunner()
450450
result = runner.invoke(update, ["--force"])
451-
# Post-update failed, but git pull succeeded — still counts as updated
452-
assert "1 server(s) updated" in result.output
451+
# Post-update failed — not counted as successful update
452+
assert "0 server(s) updated" in result.output
453453

454454
def test_apply_pull_fails(self, monkeypatch, tmp_path):
455455
"""Test that a failed pull is reported and not counted."""

0 commit comments

Comments
 (0)