fix: Update analyzer.rs, generator.rs, and prompt.rs with proper imports
This commit is contained in:
@@ -38,25 +38,6 @@ pub fn generate_alternative_messages(
|
|||||||
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 {
|
pub fn format_message(message: &str) -> String {
|
||||||
if message.len() <= 72 {
|
if message.len() <= 72 {
|
||||||
return message.to_string();
|
return message.to_string();
|
||||||
@@ -125,32 +106,6 @@ mod tests {
|
|||||||
assert_eq!(message, "fix: resolve null pointer exception");
|
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]
|
#[test]
|
||||||
fn test_format_message_short() {
|
fn test_format_message_short() {
|
||||||
let message = format_message("feat: add new feature");
|
let message = format_message("feat: add new feature");
|
||||||
|
|||||||
Reference in New Issue
Block a user