Skip to content

Commit b262f78

Browse files
committed
Refactor function calls to use single-line formatting
1 parent ed71a85 commit b262f78

File tree

3 files changed

+13
-27
lines changed

3 files changed

+13
-27
lines changed

src/commit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub async fn generate(patch: String, remaining_tokens: usize, model: Model, sett
126126
bail!("Invalid OpenAI API key. Please check your API key configuration.");
127127
}
128128
log::warn!("Parallel generation with custom settings failed, trying multi-step: {e}");
129-
129+
130130
// Fallback to old multi-step approach
131131
match generate_commit_message_multi_step(&client, &model_str, &patch, max_length).await {
132132
Ok(message) => return Ok(openai::Response { response: message }),
@@ -163,7 +163,7 @@ pub async fn generate(patch: String, remaining_tokens: usize, model: Model, sett
163163
bail!("Invalid OpenAI API key. Please check your API key configuration.");
164164
}
165165
log::warn!("Parallel generation failed, trying multi-step: {e}");
166-
166+
167167
// Fallback to old multi-step approach
168168
match generate_commit_message_multi_step(&client, &model_str, &patch, max_length).await {
169169
Ok(message) => return Ok(openai::Response { response: message }),

src/multi_step_integration.rs

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -608,16 +608,14 @@ pub async fn generate_commit_message_parallel(
608608

609609
// Phase 1: Analyze each file in parallel using simplified approach
610610
log::debug!("Starting parallel analysis of {} files", parsed_files.len());
611-
611+
612612
let analysis_futures: Vec<_> = parsed_files
613613
.iter()
614614
.map(|file| {
615615
let file_path = file.path.clone();
616616
let operation = file.operation.clone();
617617
let diff_content = file.diff_content.clone();
618-
async move {
619-
analyze_single_file_simple(client, model, &file_path, &operation, &diff_content).await
620-
}
618+
async move { analyze_single_file_simple(client, model, &file_path, &operation, &diff_content).await }
621619
})
622620
.collect();
623621

@@ -650,24 +648,15 @@ pub async fn generate_commit_message_parallel(
650648

651649
// Phase 2: Synthesize final commit message from all analyses
652650
log::debug!("Synthesizing final commit message from {} analyses", successful_analyses.len());
653-
654-
let synthesis_result = synthesize_commit_message(
655-
client,
656-
model,
657-
&successful_analyses,
658-
max_length.unwrap_or(72),
659-
).await?;
651+
652+
let synthesis_result = synthesize_commit_message(client, model, &successful_analyses, max_length.unwrap_or(72)).await?;
660653

661654
Ok(synthesis_result)
662655
}
663656

664657
/// Analyzes a single file using simplified text completion (no function calling)
665658
async fn analyze_single_file_simple(
666-
client: &Client<OpenAIConfig>,
667-
model: &str,
668-
file_path: &str,
669-
operation: &str,
670-
diff_content: &str,
659+
client: &Client<OpenAIConfig>, model: &str, file_path: &str, operation: &str, diff_content: &str
671660
) -> Result<String> {
672661
let system_prompt = "You are a git diff analyzer. Analyze the provided file change and provide a concise summary in 1-2 sentences describing what changed and why it matters.";
673662

@@ -704,10 +693,7 @@ async fn analyze_single_file_simple(
704693

705694
/// Synthesizes a final commit message from multiple file analyses
706695
async fn synthesize_commit_message(
707-
client: &Client<OpenAIConfig>,
708-
model: &str,
709-
analyses: &[(String, String)],
710-
max_length: usize,
696+
client: &Client<OpenAIConfig>, model: &str, analyses: &[(String, String)], max_length: usize
711697
) -> Result<String> {
712698
// Build context from all analyses
713699
let mut context = String::new();
@@ -1003,12 +989,12 @@ index abcd123..efgh456 100644
1003989
assert_eq!(files.len(), 2);
1004990
assert_eq!(files[0].path, "src/auth.rs");
1005991
assert_eq!(files[1].path, "src/main.rs");
1006-
992+
1007993
// Verify diff content is captured
1008994
assert!(files[0].diff_content.contains("use crate::security"));
1009995
assert!(files[1].diff_content.contains("auth::authenticate"));
1010996
}
1011-
997+
1012998
#[test]
1013999
fn test_parse_diff_edge_cases() {
10141000
// Test parsing with various git prefixes and edge cases
@@ -1025,13 +1011,13 @@ index 1234567..0000000
10251011
assert_eq!(files.len(), 1);
10261012
assert_eq!(files[0].path, "old_file.txt", "Should extract original path for deleted files");
10271013
assert_eq!(files[0].operation, "deleted");
1028-
1014+
10291015
// Test with binary files
10301016
let diff_binary = r#"diff --git a/image.png b/image.png
10311017
new file mode 100644
10321018
index 0000000..1234567
10331019
Binary files /dev/null and b/image.png differ"#;
1034-
1020+
10351021
let files = parse_diff(diff_binary).unwrap();
10361022
assert_eq!(files.len(), 1);
10371023
assert_eq!(files[0].path, "image.png");

src/openai.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pub async fn call_with_config(request: Request, config: OpenAIConfig) -> Result<
214214
return Err(e);
215215
}
216216
log::warn!("Parallel approach failed, trying multi-step: {e}");
217-
217+
218218
// Fallback to old multi-step approach
219219
match generate_commit_message_multi_step(&client, &model, &request.prompt, config::APP_CONFIG.max_commit_length).await {
220220
Ok(message) => return Ok(Response { response: message }),

0 commit comments

Comments
 (0)