1
0

Add rebase check and abort functionality in autoCommit and commitCurrentFolder

This commit is contained in:
Victor Giers
2025-12-07 22:49:48 +01:00
parent 3b5fc1c8c1
commit 4b330d0a7f

29
main.js
View File

@@ -1311,9 +1311,29 @@ function addMatchingFilesToGitignore(folderPath, pattern) {
}
function isRebaseInProgress(repoPath) {
const gitDir = path.join(repoPath, '.git');
return (
fs.existsSync(path.join(gitDir, 'rebase-merge')) ||
fs.existsSync(path.join(gitDir, 'rebase-apply'))
);
}
async function autoCommit(folderPath, message, win) {
const git = simpleGit(folderPath);
// If a previous rebase (likely from commit rewrite) is still open, abort it so auto-commit can proceed.
if (isRebaseInProgress(folderPath)) {
try {
debug(`[autoCommit] Rebase detected in ${folderPath}, aborting to unblock auto-commit.`);
await git.raw(['rebase', '--abort']);
} catch (err) {
debug(`[autoCommit] Rebase abort failed: ${err.message}`);
return false;
}
}
const status = await git.status();
if (
status.not_added.length === 0 &&
@@ -2030,6 +2050,15 @@ function buildTrayMenu() {
debug(`Commit-Vorgang für ${folder} gestartet…`);
const git = simpleGit(folder);
if (isRebaseInProgress(folder)) {
try {
debug('[commit-current-folder] Rebase detected, aborting before commit.');
await git.raw(['rebase', '--abort']);
} catch (err) {
return { success: false, error: `Rebase in progress: ${err.message}` };
}
}
// Prüfe: Gibt es was zu committen?
const status = await git.status();
if (