1
0

auto-git:

[change] main.js
This commit is contained in:
2025-05-24 14:18:03 +02:00
parent 0e8aec9713
commit a7dfb2b0ea

34
main.js
View File

@@ -327,41 +327,23 @@ async function rewriteCommitMessages(repoPath, message) {
/** /**
* Komplett-Workflow: Von Kandidaten bis Rewrite * Komplett-Workflow: Von Kandidaten bis Rewrite
*/ */
//async function runLLMCommitPipeline(folderPath, hashes, win) {
async function runLLMCommitPipeline(folderPath, hashes) { async function runLLMCommitPipeline(folderPath, hashes) {
// 1. Prompt bauen
const prompt = await generateLLMCommitMessages(folderPath, hashes); 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))).trim();
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 messageMap = {}; if (hashes.length === 1) {
//for (const entry of commitList) { // For a single commit: amend it in-place
// messageMap[entry.commit] = entry.newMessage;
//}
// 5. Rewrite
//await rewriteCommitMessages(folderPath, messageMap, hashes);
if(hashes.length == 1){
const git = simpleGit(folderPath); 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) { } 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 { } 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) { async function autoCommit(folderPath, message) {
const git = simpleGit(folderPath); const git = simpleGit(folderPath);
const status = await git.status(); const status = await git.status();
@@ -471,7 +453,7 @@ async function autoCommit(folderPath, message) {
// Reset danach: // Reset danach:
folders[idx].linesChanged = 0; folders[idx].linesChanged = 0;
folders[idx].llmCandidates = []; folders[idx].llmCandidates = [];
store.set('folders', folders); //store.set('folders', folders);
} }
// Folder-Objekt speichern // Folder-Objekt speichern