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', [