Skip to content

Commit 38ec509

Browse files
committed
add failing regression test
1 parent 9a7c044 commit 38ec509

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

tests/simple_additions.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,3 +1008,59 @@ This project is open source and available for use.
10081008
"This project is open source and available for use.".ai(),
10091009
]);
10101010
}
1011+
1012+
#[test]
1013+
fn test_constructor_parameter_removal_attribution_bug() {
1014+
// Regression test for bug where removing a constructor parameter
1015+
// doesn't get attributed to AI when using mock_ai checkpoint
1016+
// This replicates the scenario where:
1017+
// - constructor(_config: Config, enabled: boolean = true) { [no-data]
1018+
// + constructor(enabled: boolean = true) { [no-data]
1019+
// The constructor line should be attributed to AI
1020+
use std::fs;
1021+
1022+
let repo = TestRepo::new();
1023+
let file_path = repo.path().join("git-ai-integration-service.ts");
1024+
1025+
// Initial commit: File with old constructor signature (all human)
1026+
fs::write(
1027+
&file_path,
1028+
"/**\n * Service for integrating git-ai hooks into the hook system.\n */\nexport 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",
1029+
)
1030+
.unwrap();
1031+
1032+
repo.git_ai(&["checkpoint"]).unwrap();
1033+
repo.stage_all_and_commit("Initial commit with old constructor").unwrap();
1034+
1035+
// Second commit: AI removes the _config parameter
1036+
fs::write(
1037+
&file_path,
1038+
"/**\n * Service for integrating git-ai hooks into the hook system.\n */\nexport class GitAiIntegrationService {\n private readonly commandPath: string;\n private registered = false;\n\n constructor(enabled: boolean = true) {\n this.enabled = enabled;\n this.commandPath = 'git-ai';\n }\n}\n",
1039+
)
1040+
.unwrap();
1041+
1042+
// Mark the change as AI-authored
1043+
repo.git_ai(&["checkpoint", "mock_ai", "git-ai-integration-service.ts"])
1044+
.unwrap();
1045+
1046+
let commit = repo
1047+
.stage_all_and_commit("AI removes constructor parameter")
1048+
.unwrap();
1049+
1050+
// Verify line-by-line attribution - the constructor line should be AI
1051+
let mut file = repo.filename("git-ai-integration-service.ts");
1052+
file.assert_lines_and_blame(lines![
1053+
"/**".human(),
1054+
" * Service for integrating git-ai hooks into the hook system.".human(),
1055+
" */".human(),
1056+
"export class GitAiIntegrationService {".human(),
1057+
" private readonly commandPath: string;".human(),
1058+
" private registered = false;".human(),
1059+
"".human(),
1060+
" constructor(enabled: boolean = true) {".ai(), // Should be AI, not [no-data]
1061+
" this.enabled = enabled;".human(),
1062+
" this.commandPath = 'git-ai';".human(),
1063+
" }".human(),
1064+
"}".human(),
1065+
]);
1066+
}

0 commit comments

Comments
 (0)