diff --git a/index.html b/index.html
index c440035..b41bc37 100644
--- a/index.html
+++ b/index.html
@@ -183,26 +183,24 @@
-
-
-
-
diff --git a/main.js b/main.js
index 7798443..5c75d6d 100644
--- a/main.js
+++ b/main.js
@@ -12,7 +12,8 @@ const store = new Store({
folders: [],
selected: null,
skymode: true,
- skipGitPrompt: true
+ skipGitPrompt: true,
+ intelligentCommitThreshold: 100
}
});
@@ -178,8 +179,8 @@ function stopMonitoringWatcher(folderPath) {
}
}
-async function autoCommit(folder, message) {
- const git = simpleGit(folder);
+async function autoCommit(folderPath, message) {
+ const git = simpleGit(folderPath);
const status = await git.status();
if (
status.not_added.length === 0 &&
@@ -242,6 +243,36 @@ async function autoCommit(folder, message) {
}
}
+ // *** Zeilenzählung ***
+ let diffOutput = await git.diff(['--numstat']);
+ // Zeilensumme berechnen:
+ let changedLines = 0;
+ for (let line of diffOutput.split('\n')) {
+ // Format:
+ const match = line.match(/^(\d+|\-)\s+(\d+|\-)\s+(.*)$/);
+ if (match) {
+ const added = match[1] === '-' ? 0 : parseInt(match[1], 10);
+ const deleted = match[2] === '-' ? 0 : parseInt(match[2], 10);
+ changedLines += added + deleted;
+ }
+ }
+ // Folder-Objekt holen und aktualisieren
+ let folders = store.get('folders') || [];
+ let idx = folders.findIndex(f => f.path === folderPath);
+ if (idx !== -1) {
+ folders[idx].linesChanged = (folders[idx].linesChanged || 0) + changedLines;
+ store.set('folders', folders);
+
+ // Threshold holen
+ const threshold = store.get('intelligentCommitThreshold') || 10;
+ if (folders[idx].linesChanged >= threshold) {
+ folders[idx].linesChanged = 0;
+ store.set('folders', folders);
+ debug('Congratulations! You changed enough lines of code :)');
+ // Optional: Toast anzeigen, etc.
+ }
+ }
+
await git.add(['-A']);
debug('[autoCommit] Alle Änderungen gestaged.');
await git.commit(message || '[auto]');
@@ -312,7 +343,7 @@ app.whenReady().then(() => {
let folders = store.get('folders') || [];
let folderObj = folders.find(f => f.path === newFolder);
if (!folderObj) {
- folderObj = { path: newFolder, monitoring: true };
+ folderObj = { path: newFolder, monitoring: true, linesChanged: 0 };
folders.push(folderObj);
store.set('folders', folders);
}
@@ -619,6 +650,12 @@ app.whenReady().then(() => {
return monitoring;
});
+ ipcMain.handle('get-intelligent-commit-threshold', () => store.get('intelligentCommitThreshold'));
+ ipcMain.handle('set-intelligent-commit-threshold', (_e, value) => {
+ store.set('intelligentCommitThreshold', value);
+ });
+
+
// … Ende der IPC-Handler …
});
diff --git a/preload.js b/preload.js
index a592cbe..af1f1e4 100644
--- a/preload.js
+++ b/preload.js
@@ -25,6 +25,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
showFolderContextMenu: folderPath => ipcRenderer.send('show-folder-context-menu', folderPath),
setMonitoring: (folderObj, monitoring) => ipcRenderer.invoke('set-monitoring', folderObj.path, monitoring),
getFolderTree: (folderPath) => ipcRenderer.invoke('get-folder-tree', folderPath),
+ getIntelligentCommitThreshold: () => ipcRenderer.invoke('get-intelligent-commit-threshold'),
+ setIntelligentCommitThreshold: value => ipcRenderer.invoke('set-intelligent-commit-threshold', value),
});
ipcRenderer.on('repo-updated', (_e, folder) => {
diff --git a/renderer.js b/renderer.js
index fe1a439..810be44 100644
--- a/renderer.js
+++ b/renderer.js
@@ -5,6 +5,7 @@ window.addEventListener('DOMContentLoaded', async () => {
const folderList = document.getElementById('folderList');
const addBtn = document.getElementById('addFolderBtn');
const titleEl = document.getElementById('currentTitle');
+ const treeviewEl = document.getElementById('folderHierarchyDropdown');
const contentList = document.getElementById('contentList');
const panel = document.querySelector('.flex-1.p-4.overflow-y-auto');
@@ -42,8 +43,10 @@ window.addEventListener('DOMContentLoaded', async () => {
const hour = new Date().getHours();
if (hour >= 18 || hour < 6) {
titleEl.style.color = '#fff';
+ treeviewEl.style.color = '#fff';
} else {
titleEl.style.color = '';
+ treeviewEl.style.color = '';
}
}
updateTitleColor();
@@ -227,7 +230,7 @@ folders.forEach(folderObj => {
folderTitleArrow.classList.remove('open');
isDropdownOpen = false;
}
-
+
// ASCII-Baum: wie bei ChatGPT!
function renderFolderTreeAscii(tree, prefix = '', indent = '') {
if (!Array.isArray(tree)) return '';
@@ -464,72 +467,12 @@ folders.forEach(folderObj => {
commitBtn.textContent = 'Commit';
});
-
-
-
-});
-
-/*
- const folderTitleDrop = document.getElementById('folderTitleDrop');
- const folderTitleArrow = document.getElementById('folderTitleArrow');
- const folderHierarchyDropdown = document.getElementById('folderHierarchyDropdown');
- const titleEl = document.getElementById('currentTitle');
- let isDropdownOpen = false;
-
- folderTitleDrop.addEventListener('click', async () => {
- if (isDropdownOpen) {
- closeDropdown();
- return;
- }
- const selected = await window.electronAPI.getSelected();
- if (!selected || !selected.path) return;
-
- // Lade die aktuelle Ordnerhierarchie
- folderHierarchyDropdown.innerHTML = 'Lade Verzeichnis...
';
- folderHierarchyDropdown.classList.remove('hidden');
- folderHierarchyDropdown.classList.add('open');
- folderTitleArrow.classList.add('open');
- isDropdownOpen = true;
-
- const tree = await window.electronAPI.getFolderTree(selected.path);
- folderHierarchyDropdown.innerHTML = renderFolderTree(tree);
+ const inputCommitThreshold = document.getElementById('intelligentCommitThreshold');
+ window.settingsAPI.getIntelligentCommitThreshold().then(val => inputCommitThreshold.value = val);
+ inputCommitThreshold.addEventListener('change', e => {
+ const num = Math.max(1, Math.min(1000, Number(inputCommitThreshold.value)));
+ window.settingsAPI.setIntelligentCommitThreshold(num);
+ inputCommitThreshold.value = num;
});
- function closeDropdown() {
- folderHierarchyDropdown.classList.add('hidden');
- folderHierarchyDropdown.classList.remove('open');
- folderTitleArrow.classList.remove('open');
- isDropdownOpen = false;
- }
-
- // KEIN automatisches Schließen beim Klick außerhalb!
-
- function renderFolderTree(tree, level = 0) {
- if (!Array.isArray(tree)) return '';
- return `` + tree.map(node => {
- if (node.type === 'dir') {
- return `
- -
-
-
- ${node.name}
-
- ${renderFolderTree(node.children, level + 1)}
-
- `;
- } else {
- return `
- -
-
- ${node.name}
-
- `;
- }
- }).join('') + '
';
- }
-*/
\ No newline at end of file
+});
\ No newline at end of file
diff --git a/settings.html b/settings.html
index 09dcff9..8b77fd1 100644
--- a/settings.html
+++ b/settings.html
@@ -74,29 +74,57 @@
button:hover { background: #f3f4f6; }
@@ -110,6 +138,11 @@
Sky Mode
+