From c91fb5506430cb23c1be9d1621bfe29bc46fdfd7 Mon Sep 17 00:00:00 2001 From: Rod Boev Date: Tue, 4 Aug 2026 10:58:24 -0400 Subject: [PATCH] fix(#4085): restore legacy dirty contract for non-status-1 exits --- api/updates.py | 2 +- tests/test_updates.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/api/updates.py b/api/updates.py index b9797279..5e03cc5e 100644 --- a/api/updates.py +++ b/api/updates.py @@ -1281,7 +1281,7 @@ def _probe_dirty( out, ok = _run_git(['diff-index', '--quiet', 'HEAD', '--'], path, timeout=timeout) if ok: return False - if out == 'git exited with status 1' or (legacy_empty_is_dirty and not out): + if out == 'git exited with status 1' or (legacy_empty_is_dirty and (not out or out.startswith('git exited with status '))): return True logger.warning( 'git dirty probe failed; treating working-tree state as unknown: %s', diff --git a/tests/test_updates.py b/tests/test_updates.py index c4ee98f1..e51368dc 100644 --- a/tests/test_updates.py +++ b/tests/test_updates.py @@ -95,6 +95,19 @@ def test_is_dirty_preserves_legacy_empty_failure_contract(tmp_path, monkeypatch) assert updates._is_dirty(tmp_path) is True +@pytest.mark.parametrize( + 'probe_output', + ['git exited with status 2', 'git exited with status 128'], +) +def test_is_dirty_legacy_broad_status_contract(tmp_path, monkeypatch, probe_output): + (tmp_path / '.git').mkdir() + monkeypatch.setattr( + updates, '_run_git', lambda *args, **kwargs: (probe_output, False), + ) + + assert updates._is_dirty(tmp_path) is True + + @pytest.mark.parametrize( 'probe_output', [