fix: Update analyzer.rs, generator.rs, and prompt.rs with proper imports
Some checks failed
CI / lint (push) Has been cancelled
CI / build (push) Has been cancelled
CI / test (push) Has been cancelled

This commit is contained in:
2026-02-01 12:40:25 +00:00
parent 228fd5f921
commit 92197cacae

View File

@@ -38,25 +38,6 @@ pub fn generate_alternative_messages(
messages
}
fn verb_alternative_description(
verb: &str,
base: &str,
files: &[super::git::ChangedFile],
) -> String {
let file_count = files.len();
if file_count <= 3 && !files.is_empty() {
let file_names: Vec<String> = files
.iter()
.map(|f| f.path.split('/').last().unwrap_or(&f.path).to_string())
.collect();
let file_list = file_names.join(", ");
format!("{} {}", verb, file_list)
} else {
format!("{} {} files", verb, file_count)
}
}
pub fn format_message(message: &str) -> String {
if message.len() <= 72 {
return message.to_string();
@@ -125,32 +106,6 @@ mod tests {
assert_eq!(message, "fix: resolve null pointer exception");
}
#[test]
fn test_scope_extraction() {
let analysis = AnalysisResult {
commit_type: CommitType::Test,
scope: Some(String::from("api")),
confidence: 0.9,
description: String::from("add API endpoint tests"),
reasons: vec![],
};
let staged = StagedChanges {
files: vec![ChangedFile {
path: String::from("api/users_test.rs"),
old_path: None,
status: FileStatus::Added,
additions: 50,
deletions: 0,
is_new: true,
is_deleted: false,
is_renamed: false,
}],
diff_text: String::new(),
};
let message = generate_message(&analysis, &staged);
assert_eq!(message, "test(api): add API endpoint tests");
}
#[test]
fn test_format_message_short() {
let message = format_message("feat: add new feature");