try to use local ai to generate commit message

This commit is contained in:
Christoph Brandau
2026-07-02 19:59:16 +02:00
parent 2a96e79d27
commit f2aa48d2ec
13 changed files with 3889 additions and 62 deletions
+32
View File
@@ -479,6 +479,37 @@ pub fn get_file_patch(path: String, file: String, staged: bool) -> Result<String
Ok(String::from_utf8_lossy(&output).to_string())
}
#[tauri::command]
pub async fn commit_ai_status(
engine: tauri::State<'_, commit_ai::CommitAiEngine>,
) -> Result<commit_ai::CommitAiStatus, String> {
Ok(engine.status().await)
}
#[tauri::command]
pub async fn commit_ai_generate(
path: String,
notes: Option<String>,
engine: tauri::State<'_, commit_ai::CommitAiEngine>,
) -> Result<String, String> {
let repo = resolve_repo(&path)?;
let diff = run_git(
&repo,
[
"diff",
"--cached",
"--no-ext-diff",
"--no-textconv",
"--unified=3",
],
)?;
let diff = String::from_utf8_lossy(&diff).to_string();
engine
.generate_commit_message(&diff, notes.as_deref())
.await
}
#[tauri::command]
pub fn apply_file_patch(
path: String,
@@ -1573,6 +1604,7 @@ fn status_for_repo(repo: &Path) -> Result<GitStatus, String> {
let (branch, mut files) = parse_status_output(&output)?;
detect_worktree_renames(repo, &mut files);
Ok(GitStatus {
repo_path: repo.to_string_lossy().to_string(),
current_branch: branch.current_branch,