1
0

[auto] change main.js

This commit is contained in:
2025-05-23 22:55:05 +02:00
parent cb0e6267cb
commit db136fcd5e

21
main.js
View File

@@ -133,13 +133,26 @@ function startMonitoringWatcher(folderPath, win) {
// Initialer Commit, falls beim Start schon ungestagte Änderungen vorliegen // Initialer Commit, falls beim Start schon ungestagte Änderungen vorliegen
(async () => { (async () => {
debug(`[MONITOR] Starte initialen Commit-Check für ${folderPath}`); debug(`[MONITOR] Starte initialen Commit-Check für ${folderPath}`);
const event = 'startup';
const changedPath = folderPath; const git = simpleGit(folderPath);
const msg = `[auto] ${event} ${path.relative(folderPath, changedPath)}`; const status = await git.status();
// Alle betroffenen Pfade sammeln und je nach Typ annotieren
const changes = [];
status.not_added.forEach(f => changes.push(`[add] ${f}`));
status.created.forEach(f => changes.push(`[add] ${f}`));
status.modified.forEach(f => changes.push(`[modify] ${f}`));
status.deleted.forEach(f => changes.push(`[delete] ${f}`));
status.renamed.forEach(r => changes.push(`[rename] ${r.from}${r.to}`));
if (changes.length > 0) {
// Commit-Message so bauen wie beim Event (eine Zeile pro Datei)
const msg = `[auto] initial monitor: \n` + changes.map(l => ` - ${l}`).join('\n');
const did = await autoCommit(folderPath, msg); const did = await autoCommit(folderPath, msg);
if (did) { if (did) {
win.webContents.send('repo-updated', folderPath); win.webContents.send('repo-updated', folderPath);
debug(`[MONITOR] Initialer Auto-Commit für ${folderPath} durchgeführt.`); debug(`[MONITOR] Initialer Auto-Commit für ${folderPath} durchgeführt:\n${msg}`);
}
} }
})(); })();