Skip to content

Commit b03ce74

Browse files
docs(test_git): correct is_git_project test docstrings
* the 'not inside work tree' case covers both .git/ subdirs of normal repos AND the root of bare repos (which have no .git directory at all) * the substring-rejection test verifies strict full-string equality after ANSI/whitespace strip, not whole-word matching Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ee91310 commit b03ce74

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

tests/test_git.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,9 @@ def test_is_git_project_accepts_loose_true_output(mocker: MockFixture):
331331

332332

333333
def test_is_git_project_returns_false_for_bare_repo(mocker: MockFixture):
334-
"""``git rev-parse`` exits 0 but says ``false`` when run from inside the
335-
``.git`` directory of a bare repo. ``is_git_project`` is meant to gate
336-
work-tree commands, so this case should still return ``False``."""
334+
"""When ``git rev-parse --is-inside-work-tree`` returns ``false``
335+
(inside ``.git/`` of a normal repo, or at the root of a bare repo),
336+
``is_git_project`` should return ``False``."""
337337
fake = cmd.Command("false\n", "", b"", b"", 0)
338338
mocker.patch("commitizen.cmd.run", return_value=fake)
339339
assert git.is_git_project() is False
@@ -343,10 +343,9 @@ def test_is_git_project_returns_false_for_bare_repo(mocker: MockFixture):
343343
def test_is_git_project_rejects_strings_containing_true_substring(
344344
mocker: MockFixture, noise: str
345345
):
346-
"""The ``true`` token must be matched as a whole word at the end of the
347-
output, not just any string ending in ``true``. Even though git itself
348-
will never produce these strings, a defensive matcher shouldn't accept
349-
them either."""
346+
"""After stripping ANSI escapes and whitespace, only the exact string
347+
``true`` is accepted; outputs like ``untrue``, ``nottrue``, or
348+
``true false`` are rejected."""
350349
fake = cmd.Command(f"{noise}\n", "", b"", b"", 0)
351350
mocker.patch("commitizen.cmd.run", return_value=fake)
352351
assert git.is_git_project() is False

0 commit comments

Comments
 (0)