From a7dfb2b0ea19ef049eb568438bf0464340a09ccd Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 24 May 2025 14:18:03 +0200 Subject: [PATCH] auto-git: [change] main.js --- main.js | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/main.js b/main.js index 61dc865..bbee73b 100644 --- a/main.js +++ b/main.js @@ -327,41 +327,23 @@ async function rewriteCommitMessages(repoPath, message) { /** * Komplett-Workflow: Von Kandidaten bis Rewrite */ -//async function runLLMCommitPipeline(folderPath, hashes, win) { - async function runLLMCommitPipeline(folderPath, hashes) { - // 1. Prompt bauen const prompt = await generateLLMCommitMessages(folderPath, hashes); - // 2. LLM Call & Streaming Output für die Katze (optional) - const llmOutput = await streamLLMCommitMessages(prompt, chunk => process.stdout.write(chunk)); - //console.log('LLM Output:\n', llmOutput); // Nur ein einziges Mal - // 3. Robust parsen - //const commitList = parseLLMCommitMessages(llmOutput); // [{commit, newMessage}] - fuck it, maybe later something else - // 4. Hash->Message Mapping + const llmOutput = (await streamLLMCommitMessages(prompt, chunk => process.stdout.write(chunk))).trim(); - //const messageMap = {}; - //for (const entry of commitList) { - // messageMap[entry.commit] = entry.newMessage; - //} - // 5. Rewrite - //await rewriteCommitMessages(folderPath, messageMap, hashes); - if(hashes.length == 1){ + if (hashes.length === 1) { + // For a single commit: amend it in-place const git = simpleGit(folderPath); - await git.raw(['commit', '--amend', '-m', message, '--no-edit', '--allow-empty']); + await git.raw(['commit', '--amend', '-m', llmOutput, '--no-edit', '--allow-empty']); } else if (hashes.length > 1) { - await squashCommitMessages(folderPath, llmOutput, hashes); //WE NEED THIS FUNCTION, WRITE IT PLEASE + // For multiple commits: squash & set message + await squashCommitMessages(folderPath, llmOutput, hashes); } else { - //should never be reached, right? + throw new Error('No commits to rewrite.'); } - - // Optional: Notification anzeigen - //if (win && win.webContents) { - // win.webContents.send('llm-commit-rewrite-finished', { changed: hashes.length }); - //} } - async function autoCommit(folderPath, message) { const git = simpleGit(folderPath); const status = await git.status(); @@ -471,7 +453,7 @@ async function autoCommit(folderPath, message) { // Reset danach: folders[idx].linesChanged = 0; folders[idx].llmCandidates = []; - store.set('folders', folders); + //store.set('folders', folders); } // Folder-Objekt speichern