@@ -350,3 +350,34 @@ def test_check_command_with_comment_in_messege_file(mocker: MockFixture, capsys)
350350 cli .main ()
351351 out , _ = capsys .readouterr ()
352352 assert "Commit validation: successful!" in out
353+
354+
355+ def test_check_conventional_commit_succeed_with_git_diff (mocker , capsys ):
356+ commit_msg = (
357+ "feat: This is a test commit\n "
358+ "# Please enter the commit message for your changes. Lines starting\n "
359+ "# with '#' will be ignored, and an empty message aborts the commit.\n "
360+ "#\n "
361+ "# On branch ...\n "
362+ "# Changes to be committed:\n "
363+ "# modified: ...\n "
364+ "#\n "
365+ "# ------------------------ >8 ------------------------\n "
366+ "# Do not modify or remove the line above.\n "
367+ "# Everything below it will be ignored.\n "
368+ "diff --git a/... b/...\n "
369+ "index f1234c..1c5678 1234\n "
370+ "--- a/...\n "
371+ "+++ b/...\n "
372+ "@@ -92,3 +92,4 @@ class Command(BaseCommand):\n "
373+ '+ "this is a test"\n '
374+ )
375+ testargs = ["cz" , "check" , "--commit-msg-file" , "some_file" ]
376+ mocker .patch .object (sys , "argv" , testargs )
377+ mocker .patch (
378+ "commitizen.commands.check.open" ,
379+ mocker .mock_open (read_data = commit_msg ),
380+ )
381+ cli .main ()
382+ out , _ = capsys .readouterr ()
383+ assert "Commit validation: successful!" in out
0 commit comments