@@ -423,19 +423,53 @@ def test_a_commit_in_the_clone_carries_its_own_author(self):
423423 self .assertEqual (env ["GIT_AUTHOR_EMAIL" ], "bot@renovateapp.com" )
424424
425425 def test_message_ai_attribution_checks_only_the_ai_rules (self ):
426- """The commit still goes in with its author, so CC017 judges it."""
426+ """The format rules' verdicts are dropped; the commit still goes in
427+ with its author, so CC017 judges it."""
427428 self .local_author .return_value = ("Jane Dev" , "jane@example.com" )
428- mock_result = MagicMock (returncode = 0 , stdout = json_output (make_check ("message" )))
429+ output = json_output (
430+ make_check ("message" , status = "fail" ),
431+ make_check ("ai_author" , status = "fail" , rule_id = "CC017" ),
432+ make_check ("ai_co_author" , rule_id = "CC015" ),
433+ )
434+ mock_result = MagicMock (returncode = 1 , stdout = output )
429435 with (
430436 patch ("main.MESSAGE_AI_ATTRIBUTION_ENABLED" , True ),
431437 patch ("main.subprocess.run" , return_value = mock_result ) as mock_run ,
432438 ):
433- main .run_pr_message_checks ([(SHA_A , "WIP" )])
439+ [ scope ] = main .run_pr_message_checks ([(SHA_A , "WIP" )])
434440 self .assertEqual (
435- mock_run .call_args [0 ][0 ],
436- ["commit-check" , "--format" , "json" , "--message-ai-attribution" ],
441+ mock_run .call_args [0 ][0 ], ["commit-check" , "--format" , "json" , "--message" ]
437442 )
438443 self .assertEqual (mock_run .call_args [1 ]["env" ]["GIT_AUTHOR_NAME" ], "Jane Dev" )
444+ self .assertEqual ([c ["rule_id" ] for c in scope .checks ], ["CC017" , "CC015" ])
445+ self .assertEqual (scope .status , "fail" )
446+
447+ def test_message_ai_attribution_passes_a_badly_formatted_message (self ):
448+ mock_result = MagicMock (
449+ returncode = 1 ,
450+ stdout = json_output (
451+ make_check ("message" , status = "fail" ),
452+ make_check ("subject_min_length" , status = "fail" , rule_id = "CC005" ),
453+ make_check ("ai_attribution" , rule_id = "CC013" ),
454+ ),
455+ )
456+ with (
457+ patch ("main.MESSAGE_AI_ATTRIBUTION_ENABLED" , True ),
458+ patch ("main.subprocess.run" , return_value = mock_result ),
459+ ):
460+ [scope ] = main .run_pr_message_checks ([(SHA_A , "WIP" )])
461+ self .assertEqual (scope .status , "pass" )
462+
463+ def test_message_ai_attribution_under_ignore_is_skipped (self ):
464+ """No AI rule ran: say so rather than report a pass."""
465+ mock_result = MagicMock (returncode = 0 , stdout = json_output (make_check ("message" )))
466+ with (
467+ patch ("main.MESSAGE_AI_ATTRIBUTION_ENABLED" , True ),
468+ patch ("main.subprocess.run" , return_value = mock_result ),
469+ ):
470+ [scope ] = main .run_pr_message_checks ([(SHA_A , "feat: x" )])
471+ self .assertEqual (scope .status , "skip" )
472+ self .assertEqual (scope .checks [0 ]["reason" ], main .AI_POLICY_IGNORED )
439473
440474 def test_a_blank_author_field_is_left_to_git (self ):
441475 self .local_author .return_value = ("Renovate Bot" , "" )
@@ -1009,9 +1043,7 @@ def test_message_ai_attribution_narrows_the_head_check(self):
10091043 patch ("main.run_other_checks" , return_value = []),
10101044 ):
10111045 main .run_commit_check ()
1012- mock_scope .assert_called_once_with (
1013- "Commit message" , ["--message-ai-attribution" ], sha = SHA_A
1014- )
1046+ mock_scope .assert_called_once_with ("Commit message" , ["--message" ], sha = SHA_A )
10151047
10161048 def test_message_flag_removed_before_other_checks_in_pr (self ):
10171049 captured_args = []
0 commit comments