mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-19 10:43:08 +00:00
fix: Improve error handling and state management in auto-mode and utilities
This commit is contained in:
@@ -92,20 +92,22 @@ export async function stashChanges(
|
||||
}
|
||||
args.push('-m', message);
|
||||
|
||||
await execGitCommandWithLockRetry(args, cwd);
|
||||
const stdout = await execGitCommandWithLockRetry(args, cwd);
|
||||
|
||||
// git exits 0 but prints a benign message when there is nothing to stash
|
||||
const stdoutLower = stdout.toLowerCase();
|
||||
if (
|
||||
stdoutLower.includes('no local changes to save') ||
|
||||
stdoutLower.includes('nothing to stash')
|
||||
) {
|
||||
logger.debug('stashChanges: nothing to stash', { cwd, message, stdout });
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
|
||||
// "Nothing to stash" is benign – no work was lost, just return false
|
||||
if (
|
||||
errorMsg.toLowerCase().includes('no local changes to save') ||
|
||||
errorMsg.toLowerCase().includes('nothing to stash')
|
||||
) {
|
||||
logger.debug('stashChanges: nothing to stash', { cwd, message, error: errorMsg });
|
||||
return false;
|
||||
}
|
||||
|
||||
// Unexpected error – log full details and re-throw so the caller aborts
|
||||
// rather than proceeding with an un-stashed working tree
|
||||
logger.error('stashChanges: unexpected error during stash', {
|
||||
|
||||
Reference in New Issue
Block a user