@@ -1010,7 +1010,7 @@ This project is open source and available for use.
10101010}
10111011
10121012#[ test]
1013- fn test_constructor_parameter_removal_attribution_bug ( ) {
1013+ fn test_deletion_within_a_single_line_attribution ( ) {
10141014 // Regression test for bug where removing a constructor parameter
10151015 // doesn't get attributed to AI when using mock_ai checkpoint
10161016 // This replicates the scenario where:
@@ -1043,8 +1043,7 @@ fn test_constructor_parameter_removal_attribution_bug() {
10431043 repo. git_ai ( & [ "checkpoint" , "mock_ai" , "git-ai-integration-service.ts" ] )
10441044 . unwrap ( ) ;
10451045
1046- let commit = repo
1047- . stage_all_and_commit ( "AI removes constructor parameter" )
1046+ repo. stage_all_and_commit ( "AI removes constructor parameter" )
10481047 . unwrap ( ) ;
10491048
10501049 // Verify line-by-line attribution - the constructor line should be AI
@@ -1064,3 +1063,58 @@ fn test_constructor_parameter_removal_attribution_bug() {
10641063 "}" . human( ) ,
10651064 ] ) ;
10661065}
1066+
1067+ #[ test]
1068+ fn test_deletion_of_multiple_lines_by_ai ( ) {
1069+ // Regression test for bug where removing a constructor parameter
1070+ // doesn't get attributed to AI when using mock_ai checkpoint
1071+ // This replicates the scenario where:
1072+ // - constructor(_config: Config, enabled: boolean = true) { [no-data]
1073+ // + constructor(enabled: boolean = true) { [no-data]
1074+ // The constructor line should be attributed to AI
1075+ use std:: fs;
1076+
1077+ let repo = TestRepo :: new ( ) ;
1078+ let file_path = repo. path ( ) . join ( "git-ai-integration-service.ts" ) ;
1079+
1080+ // Initial commit: File with old constructor signature (all human)
1081+ fs:: write (
1082+ & file_path,
1083+ "/**\n * Service for integrating git-ai hooks into the hook system.\n */\n export class GitAiIntegrationService {\n private readonly commandPath: string;\n private registered = false;\n \n constructor(_config: Config, enabled: boolean = true) {\n this.enabled = enabled;\n this.commandPath = 'git-ai';\n }\n }\n " ,
1084+ )
1085+ . unwrap ( ) ;
1086+
1087+ repo. git_ai ( & [ "checkpoint" ] ) . unwrap ( ) ;
1088+ repo. stage_all_and_commit ( "Initial commit with old constructor" ) . unwrap ( ) ;
1089+
1090+ // Second commit: AI removes the _config parameter
1091+ fs:: write (
1092+ & file_path,
1093+ "/**\n * Service for integrating git-ai hooks into the hook system.\n */\n export class GitAiIntegrationService {\n private readonly commandPath: string;\n constructor(_config: Config, enabled: boolean = true) {\n this.commandPath = 'git-ai';\n }\n }\n " ,
1094+ )
1095+ . unwrap ( ) ;
1096+
1097+ // Mark the change as AI-authored
1098+ repo. git_ai ( & [ "checkpoint" , "mock_ai" , "git-ai-integration-service.ts" ] )
1099+ . unwrap ( ) ;
1100+
1101+ repo. stage_all_and_commit ( "AI removes constructor parameter" )
1102+ . unwrap ( ) ;
1103+
1104+ // Verify line-by-line attribution - the constructor line should be AI
1105+ let mut file = repo. filename ( "git-ai-integration-service.ts" ) ;
1106+ file. assert_lines_and_blame ( lines ! [
1107+ "/**" . human( ) ,
1108+ " * Service for integrating git-ai hooks into the hook system." . human( ) ,
1109+ " */" . human( ) ,
1110+ "export class GitAiIntegrationService {" . human( ) ,
1111+ " private readonly commandPath: string;" . human( ) ,
1112+ // " private registered = false;".human(),
1113+ // "".human(),
1114+ " constructor(_config: Config, enabled: boolean = true) {" . human( ) ,
1115+ // " this.enabled = enabled;".human(),
1116+ " this.commandPath = 'git-ai';" . human( ) ,
1117+ " }" . human( ) ,
1118+ "}" . human( ) ,
1119+ ] ) ;
1120+ }
0 commit comments