fix(#4085): restore legacy dirty contract for non-status-1 exits
This commit is contained in:
1 parent
f6903c4f34
commit
c91fb55064
2 files changed
+14
-1
No files matched your search
+1
-1
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
[
|
||||
|
||||
Reference in new issue
Block a user