From 4e924c91705c9d8561a5606a11fa5fd14f60522e Mon Sep 17 00:00:00 2001 From: nia-sg-bot Date: Tue, 15 Sep 2026 15:02:35 +0530 Subject: [PATCH] test(snapshot): cover tracked undecodable path warnings --- tests/test_git_snapshot.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_git_snapshot.py b/tests/test_git_snapshot.py index 8b591a7..d2d55d9 100644 --- a/tests/test_git_snapshot.py +++ b/tests/test_git_snapshot.py @@ -316,6 +316,33 @@ def test_undecodable_untracked_path_is_a_scoped_warning(tmp_path): ] +def test_staged_undecodable_tracked_path_is_a_scoped_warning(tmp_path): + """One invalid tracked pathname must not hide valid staged provenance.""" + repo = make_repo(tmp_path) + write(repo, "good.py", b"before = 1\n") + raw_path = os.fsencode(repo) + b"/bad-\xff.py" + with open(raw_path, "wb") as handle: + handle.write(b"before = 2\n") + commit_all(repo) + + write(repo, "good.py", b"after = 1\n") + with open(raw_path, "wb") as handle: + handle.write(b"after = 2\n") + git(repo, "add", "-A") + + result = resolve_staged(str(repo)) + + assert len(result.entries) == 1 + entry = result.entries[0] + assert entry.status == "M" + assert entry.old_path == entry.new_path == "good.py" + assert entry.old_oid == oid(repo, "HEAD:good.py") + assert entry.new_oid == index_oid(repo, "good.py") + assert [(warning.code, warning.path) for warning in result.warnings] == [ + ("undecodable_path", "bad-\\xff.py") + ] + + def test_repeated_resolution_is_deterministic(tmp_path): repo = make_repo(tmp_path) for name in ("z.txt", "a.txt", "middle.txt"):