Skip to content

Commit 494950e

Browse files
cliffhallclaude
andcommitted
test(git): mark the tests that pin known bugs
These suites are characterization tests: they assert current behavior so the SDK v2 port can prove it changed nothing. Some of that behavior is wrong, and a reader could not tell those tests from the ones that pin correct behavior. Every test that pins a known bug now carries one marker line directly above it (above any decorators): # KNOWN BUG #<issue>: pins current (wrong) behavior; the fix changes this assertion. # KNOWN BUG (no issue): <what is wrong>; the fix changes this assertion. so `git grep "KNOWN BUG"` lists exactly the tests a bug fix will have to change. Regression guards (#628, the #4550 restriction tests, the CVE-2026-27735 path checks) and pins of deliberate design are left unmarked. Comments only; no assertion changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 10f628e commit 494950e

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎src/git/tests/test_entrypoints.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ async def test_serve_logs_the_repository_it_uses(
3838
assert f"Using repository at {root}" in caplog.text
3939

4040

41+
# KNOWN BUG #3029: pins current (wrong) behavior; the fix changes this assertion.
4142
async def test_serve_returns_early_for_repository_subdirectory(
4243
repo: git.Repo, caplog: pytest.LogCaptureFixture
4344
):
@@ -71,6 +72,7 @@ async def test_serve_returns_early_for_non_repository(
7172
assert f"{tmp_path} is not a valid Git repository" in caplog.text
7273

7374

75+
# KNOWN BUG (no issue): a nonexistent --repository escapes serve() as NoSuchPathError instead of a logged error; the fix changes this assertion.
7476
async def test_serve_raises_for_nonexistent_repository(tmp_path: Path):
7577
# Characterization: serve() catches only InvalidGitRepositoryError, so a
7678
# nonexistent path escapes as NoSuchPathError and kills the server with a
@@ -165,6 +167,7 @@ def test_python_dash_m_calls_main():
165167
fake_main.assert_called_once_with()
166168

167169

170+
# KNOWN BUG (no issue): a nonexistent --repository kills the server with a Python traceback instead of a one-line error; the fix changes this assertion.
168171
def test_console_script_nonexistent_repository_exits_with_traceback(tmp_path: Path):
169172
# The one subprocess test: the installed entry point, end to end. A
170173
# nonexistent --repository is not caught (see

‎src/git/tests/test_protocol.py‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
asserts on what a client receives: the wire JSON of the tool list and of each
55
tool result. They pin the server's *current* behavior on `mcp` 1.x, bugs
66
included, as the regression net for the SDK v2 port (#4851). A test that pins a
7-
known bug says so and cites the issue; fixing the bug means changing that test.
7+
known bug says so and cites the issue (or says "no issue"); fixing the bug
8+
means changing that test.
89
"""
910

1011
import json
@@ -57,6 +58,7 @@ def staged_paths(repo: git.Repo) -> set[str]:
5758
# --------------------------------------------------------------------------
5859

5960

61+
# KNOWN BUG #360: pins current (wrong) behavior; the fix changes this assertion.
6062
async def test_initialize_reports_sdk_version_as_server_version(repo: git.Repo):
6163
# Pins #360: serverInfo.version is the `mcp` SDK's version, not this
6264
# package's, because serve() builds `Server("mcp-git")` without a version.
@@ -113,6 +115,7 @@ async def test_unknown_tool_is_error(repo: git.Repo):
113115
) == text_result("Unknown tool: git_nope", is_error=True)
114116

115117

118+
# KNOWN BUG (no issue): an unknown tool called without repo_path reports the KeyError repr "'repo_path'" instead of "Unknown tool"; the fix changes this assertion.
116119
async def test_unknown_tool_without_repo_path_reports_the_key_error():
117120
# An unlisted tool skips schema validation, so call_tool's
118121
# `arguments["repo_path"]` raises KeyError and its repr is the message.
@@ -267,6 +270,7 @@ async def test_git_diff_unknown_target_is_error(repo: git.Repo):
267270
) == text_result("Ref 'nope' did not resolve to an object", is_error=True)
268271

269272

273+
# KNOWN BUG (no issue): the flag-injection guard's message reaches the client wrapped as "Ref '...' did not resolve to an object"; the fix changes this assertion.
270274
async def test_git_diff_rejects_flag_injection(repo: git.Repo):
271275
assert await call(
272276
None,
@@ -295,6 +299,7 @@ async def test_git_commit_records_staged_changes(repo: git.Repo):
295299
assert "new.txt" in head.stats.files
296300

297301

302+
# KNOWN BUG #4762: pins current (wrong) behavior; the fix changes this assertion.
298303
async def test_git_commit_with_nothing_staged_creates_empty_commit(repo: git.Repo):
299304
# Pins #4762: with nothing staged, git_commit still writes a commit (whose
300305
# tree equals its parent's) and reports success. `git commit` would refuse
@@ -367,6 +372,7 @@ async def test_git_add_file_starting_with_dash_is_a_path(repo: git.Repo):
367372
assert staged_paths(repo) == {"-n"}
368373

369374

375+
# KNOWN BUG #4763: pins current (wrong) behavior; the fix changes this assertion.
370376
async def test_git_add_empty_list_reports_success_but_stages_nothing(
371377
repo: git.Repo,
372378
):
@@ -379,6 +385,7 @@ async def test_git_add_empty_list_reports_success_but_stages_nothing(
379385
assert staged_paths(repo) == set()
380386

381387

388+
# KNOWN BUG #4763: pins current (wrong) behavior; the fix changes this assertion.
382389
async def test_git_add_dot_on_clean_tree_reports_success(repo: git.Repo):
383390
# Pins #4763: nothing to stage, success reported anyway.
384391
result = await call(
@@ -596,6 +603,7 @@ async def test_git_create_branch_unknown_base_is_error(repo: git.Repo):
596603
) == text_result("No item found with id nope", is_error=True)
597604

598605

606+
# KNOWN BUG (no issue): git_create_branch reports "Created branch" for an existing branch already at the base commit; the fix changes this assertion.
599607
async def test_git_create_branch_existing_name_at_same_commit_reports_success(
600608
repo: git.Repo,
601609
):
@@ -624,6 +632,7 @@ async def test_git_create_branch_existing_name_at_other_commit_is_error(
624632
assert "already exist" in result["content"][0]["text"]
625633

626634

635+
# KNOWN BUG (no issue): the flag-injection guard's message reaches the client wrapped as "Ref '...' did not resolve to an object"; the fix changes this assertion.
627636
async def test_git_create_branch_rejects_flag_injection(repo: git.Repo):
628637
root = str(root_of(repo))
629638
assert await call(
@@ -652,6 +661,7 @@ async def test_git_checkout_branch(repo: git.Repo):
652661
assert repo.active_branch.name == "feature"
653662

654663

664+
# KNOWN BUG #4804: pins current (wrong) behavior; the fix changes this assertion.
655665
@pytest.mark.parametrize("revision", ["sha", "tag", "HEAD~1", "refs/heads/feature"])
656666
async def test_git_checkout_non_branch_detaches_head_but_claims_switch(
657667
repo: git.Repo, revision: str
@@ -682,6 +692,7 @@ async def test_git_checkout_unknown_branch_is_error(repo: git.Repo):
682692
assert repo.active_branch.name == "main"
683693

684694

695+
# KNOWN BUG (no issue): the flag-injection guard's message reaches the client wrapped as "Ref '...' did not resolve to an object"; the fix changes this assertion.
685696
async def test_git_checkout_rejects_flag_injection(repo: git.Repo):
686697
assert await call(
687698
None,
@@ -717,6 +728,7 @@ def show_header(commit: git.Commit) -> str:
717728
)
718729

719730

731+
# KNOWN BUG (no issue): git_show prints Python reprs (quoted sha, <git.Actor>, datetime with a memory address) instead of git's format; the fix changes this assertion.
720732
async def test_git_show_commit_with_parent(repo: git.Repo):
721733
root = root_of(repo)
722734
(root / "test.txt").write_text("line 1\nline 2\nSHOWN\nline 4\nline 5\n")
@@ -737,6 +749,7 @@ async def test_git_show_commit_with_parent(repo: git.Repo):
737749
assert "Message: 'show me'\n" in text
738750

739751

752+
# KNOWN BUG (no issue): git_show prints Python reprs (with a memory address) and "--- None" where git prints /dev/null; the fix changes this assertion.
740753
async def test_git_show_initial_commit_diffs_against_empty_tree(repo: git.Repo):
741754
# With no parent the commit is diffed against NULL_TREE. An added file has
742755
# no a_path, so the header prints Python's `None` where git prints
@@ -752,6 +765,7 @@ async def test_git_show_initial_commit_diffs_against_empty_tree(repo: git.Repo):
752765
)
753766

754767

768+
# KNOWN BUG (no issue): git_show prints Python reprs (quoted sha, <git.Actor>, datetime with a memory address) instead of git's format; the fix changes this assertion.
755769
async def test_git_show_rename_only_commit_has_header_and_no_patch(repo: git.Repo):
756770
# A pure rename yields a diff entry whose patch is empty bytes.
757771
repo.index.move(["test.txt", "renamed.txt"])
@@ -764,6 +778,7 @@ async def test_git_show_rename_only_commit_has_header_and_no_patch(repo: git.Rep
764778
)
765779

766780

781+
# KNOWN BUG (no issue): git_show prints Python reprs (quoted sha, <git.Actor>, datetime with a memory address) instead of git's format; the fix changes this assertion.
767782
async def test_git_show_binary_commit(repo: git.Repo):
768783
root = root_of(repo)
769784
(root / "blob.bin").write_bytes(bytes(range(256)))
@@ -777,6 +792,7 @@ async def test_git_show_binary_commit(repo: git.Repo):
777792
)
778793

779794

795+
# KNOWN BUG (no issue): git_show decodes the patch as strict UTF-8, so a Latin-1 file fails the whole call; the fix changes this assertion.
780796
async def test_git_show_non_utf8_patch_is_decode_error(repo: git.Repo):
781797
# Characterization: the patch bytes are decoded as strict UTF-8, so a
782798
# Latin-1 text file makes the whole call fail.
@@ -789,8 +805,9 @@ async def test_git_show_non_utf8_patch_is_decode_error(repo: git.Repo):
789805
assert "codec can't decode byte 0xe9" in result["content"][0]["text"]
790806

791807

808+
# KNOWN BUG #1682: pins current (wrong) behavior; the fix changes this assertion.
792809
async def test_git_show_revision_path_syntax_is_error(repo: git.Repo):
793-
# Regression guard for #1682: `<rev>:<path>` names a blob, not a commit,
810+
# Pins #1682's current error: `<rev>:<path>` names a blob, not a commit,
794811
# and repo.commit() appends `^0`, so the call fails with this message
795812
# rather than crashing the server.
796813
result = await call(
@@ -809,6 +826,7 @@ async def test_git_show_unknown_revision_is_error(repo: git.Repo):
809826
) == text_result("Ref 'nope' did not resolve to an object", is_error=True)
810827

811828

829+
# KNOWN BUG (no issue): the flag-injection guard's message reaches the client wrapped as "Ref '...' did not resolve to an object"; the fix changes this assertion.
812830
async def test_git_show_rejects_flag_injection(repo: git.Repo):
813831
assert await call(
814832
None, "git_show", {"repo_path": str(root_of(repo)), "revision": "--format=x"}
@@ -867,6 +885,7 @@ async def test_git_branch_contains_and_not_contains(repo: git.Repo):
867885
assert not_contains == text_result("* main")
868886

869887

888+
# KNOWN BUG (no issue): git_branch returns an unknown branch_type as a successful result, not an error; the fix changes this assertion.
870889
async def test_git_branch_unknown_type_is_not_an_error(repo: git.Repo):
871890
# Characterization: an unknown branch_type is reported in the text of a
872891
# *successful* result (isError false), so a client cannot tell it apart
@@ -876,6 +895,7 @@ async def test_git_branch_unknown_type_is_not_an_error(repo: git.Repo):
876895
) == text_result("Invalid branch type: bogus")
877896

878897

898+
# KNOWN BUG (no issue): the flag-injection guard's message reaches the client wrapped as "Ref '...' did not resolve to an object"; the fix changes this assertion.
879899
async def test_git_branch_rejects_flag_injection(repo: git.Repo):
880900
root = str(root_of(repo))
881901
assert await call(

0 commit comments

Comments
 (0)