test
This commit is contained in:
@@ -179,8 +179,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="catSlot" class="absolute bottom-12 right-2"></div>
|
<div id="catSlot" class="absolute bottom-12 right-2"></div>
|
||||||
|
<!-- Interaction bar am unteren Rand -->
|
||||||
<div class="w-full h-16 flex items-center p-4"
|
<div class="w-full h-16 flex items-center p-4"
|
||||||
style="background: var(--bg-sidebar); border-top: 1px solid var(--border)">
|
style="background: var(--bg-sidebar); border-top: 1px solid var(--border)">
|
||||||
|
<button id="commitBtn"
|
||||||
|
class="ml-auto px-4 py-2 border rounded font-semibold"
|
||||||
|
style="background: var(--accent); color: #fff; border-color: var(--border)">
|
||||||
|
Commit
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="renderer.js"></script>
|
<script src="renderer.js"></script>
|
||||||
|
|||||||
59
main.js
59
main.js
@@ -19,6 +19,11 @@ const store = new Store({
|
|||||||
// Map zum Speichern der Watcher pro Ordner
|
// Map zum Speichern der Watcher pro Ordner
|
||||||
const repoWatchers = new Map();
|
const repoWatchers = new Map();
|
||||||
|
|
||||||
|
// Debug Helper
|
||||||
|
function debug(msg) {
|
||||||
|
console.log(`[DEBUG ${new Date().toISOString()}] ${msg}`);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Erstellt das BrowserWindow und lädt index.html.
|
* Erstellt das BrowserWindow und lädt index.html.
|
||||||
* Gibt das Window-Objekt zurück.
|
* Gibt das Window-Objekt zurück.
|
||||||
@@ -288,6 +293,60 @@ ipcMain.on('show-folder-context-menu', (event, folderPath) => {
|
|||||||
];
|
];
|
||||||
const menu = Menu.buildFromTemplate(template);
|
const menu = Menu.buildFromTemplate(template);
|
||||||
menu.popup({ window: win });
|
menu.popup({ window: win });
|
||||||
|
|
||||||
|
// main.js
|
||||||
|
|
||||||
|
const simpleGit = require('simple-git');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
// Debug Helper
|
||||||
|
function debug(msg) {
|
||||||
|
console.log(`[DEBUG ${new Date().toISOString()}] ${msg}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
ipcMain.handle('commit-current-folder', async (_e, folder, message) => {
|
||||||
|
try {
|
||||||
|
debug(`Commit-Vorgang für ${folder} gestartet…`);
|
||||||
|
const git = simpleGit(folder);
|
||||||
|
|
||||||
|
// HEAD-Status prüfen
|
||||||
|
let currentBranch = null;
|
||||||
|
try {
|
||||||
|
currentBranch = (await git.revparse(['--abbrev-ref', 'HEAD'])).trim();
|
||||||
|
debug(`Aktueller Branch: ${currentBranch}`);
|
||||||
|
} catch (err) {
|
||||||
|
debug('HEAD ist detached.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wenn detached, alten Branch umbenennen und neuen master erzeugen
|
||||||
|
if (!currentBranch || currentBranch === 'HEAD') {
|
||||||
|
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
||||||
|
const backupBranch = `backup-master-${timestamp}`;
|
||||||
|
|
||||||
|
// Alten master umbenennen (nur falls vorhanden!)
|
||||||
|
const branches = await git.branchLocal();
|
||||||
|
if (branches.all.includes('master')) {
|
||||||
|
await git.branch(['-m', 'master', backupBranch]);
|
||||||
|
debug(`Alter master-Branch wurde in ${backupBranch} umbenannt.`);
|
||||||
|
}
|
||||||
|
// Neuer master-Branch
|
||||||
|
await git.checkout(['-b', 'master']);
|
||||||
|
debug('Neuer master-Branch erstellt und ausgecheckt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
await git.add(['-A']);
|
||||||
|
debug('Alle Änderungen gestaged.');
|
||||||
|
await git.commit(message || 'test');
|
||||||
|
debug('Commit erfolgreich erstellt.');
|
||||||
|
await git.push(['-u', 'origin', 'master']);
|
||||||
|
debug('Push auf origin/master erfolgreich.');
|
||||||
|
|
||||||
|
return { success: true };
|
||||||
|
} catch (err) {
|
||||||
|
debug(`FEHLER beim Commit: ${err.message}`);
|
||||||
|
return { success: false, error: err.message };
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// clean up on exit
|
// clean up on exit
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
|||||||
getSkipPrompt: () => ipcRenderer.invoke('get-skip-git-prompt'),
|
getSkipPrompt: () => ipcRenderer.invoke('get-skip-git-prompt'),
|
||||||
setSkipPrompt: val => ipcRenderer.invoke('set-skip-git-prompt', val),
|
setSkipPrompt: val => ipcRenderer.invoke('set-skip-git-prompt', val),
|
||||||
showFolderContextMenu: folderPath => ipcRenderer.send('show-folder-context-menu', folderPath),
|
showFolderContextMenu: folderPath => ipcRenderer.send('show-folder-context-menu', folderPath),
|
||||||
|
commitCurrentFolder: (folder, message) => ipcRenderer.invoke('commit-current-folder', folder, message),
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcRenderer.on('repo-updated', (_e, folder) => {
|
ipcRenderer.on('repo-updated', (_e, folder) => {
|
||||||
|
|||||||
34
renderer.js
34
renderer.js
@@ -8,6 +8,11 @@ window.addEventListener('DOMContentLoaded', async () => {
|
|||||||
const contentList = document.getElementById('contentList');
|
const contentList = document.getElementById('contentList');
|
||||||
const panel = document.querySelector('.flex-1.p-4.overflow-y-auto');
|
const panel = document.querySelector('.flex-1.p-4.overflow-y-auto');
|
||||||
|
|
||||||
|
const commitBtn = document.getElementById('commitBtn');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 1) Baby-Blau und Nacht-Blau als RGB-Arrays
|
// 1) Baby-Blau und Nacht-Blau als RGB-Arrays
|
||||||
const DAY_COLOR = [173, 216, 230];
|
const DAY_COLOR = [173, 216, 230];
|
||||||
const NIGHT_COLOR = [0, 0, 50];
|
const NIGHT_COLOR = [0, 0, 50];
|
||||||
@@ -394,4 +399,33 @@ async function renderSidebar() {
|
|||||||
window.electronAPI.showFolderContextMenu(titleEl.textContent);
|
window.electronAPI.showFolderContextMenu(titleEl.textContent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
commitBtn.addEventListener('click', async () => {
|
||||||
|
const folder = await window.electronAPI.getSelected();
|
||||||
|
console.log('[DEBUG] Selected folder for commit:', folder);
|
||||||
|
|
||||||
|
if (!folder || folder === 'No folder selected') {
|
||||||
|
alert('Kein Ordner ausgewählt!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const message = prompt('Commit-Nachricht:', 'test');
|
||||||
|
if (!message) return;
|
||||||
|
|
||||||
|
commitBtn.disabled = true;
|
||||||
|
commitBtn.textContent = 'Committing...';
|
||||||
|
|
||||||
|
const result = await window.electronAPI.commitCurrentFolder(folder, message);
|
||||||
|
console.log('[DEBUG] Commit result:', result);
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
alert('Commit erfolgreich!');
|
||||||
|
await renderContent(folder); // ← refresht Commit-Liste!
|
||||||
|
} else {
|
||||||
|
alert('Commit fehlgeschlagen:\n' + result.error);
|
||||||
|
}
|
||||||
|
commitBtn.disabled = false;
|
||||||
|
commitBtn.textContent = 'Commit';
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user