fix(#4085): restore legacy dirty contract for non-status-1 exits

This commit is contained in:
Rod Boev committed 2026-08-04 10:58:24 -04:00
1 parent f6903c4f34
commit c91fb55064
2 files changed
+14 -1

No files matched your search

+1 -1
View File
@@ -1281,7 +1281,7 @@ def _probe_dirty(
out, ok = _run_git(['diff-index', '--quiet', 'HEAD', '--'], path, timeout=timeout) out, ok = _run_git(['diff-index', '--quiet', 'HEAD', '--'], path, timeout=timeout)
if ok: if ok:
return False 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 return True
logger.warning( logger.warning(
'git dirty probe failed; treating working-tree state as unknown: %s', 'git dirty probe failed; treating working-tree state as unknown: %s',
+13
View File
@@ -95,6 +95,19 @@ def test_is_dirty_preserves_legacy_empty_failure_contract(tmp_path, monkeypatch)
assert updates._is_dirty(tmp_path) is True 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( @pytest.mark.parametrize(
'probe_output', 'probe_output',
[ [