Add rebase check and abort functionality in autoCommit and commitCurrentFolder
This commit is contained in:
29
main.js
29
main.js
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user