Skip to content

Commit

Permalink
More fix
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-centore committed May 13, 2024
1 parent 2ecd726 commit 3e32dac
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,25 +123,38 @@ ipcMain.handle('run-cmds', async (_event, data) => {
}

for (const command of data as Command[]) {
const result = await spawnTerminal({
command,
dir,
mainWindow,
});
if (result.returnCode !== 0) {
if (
result.out?.includes(
'Another git process seems to be running in this repository',
)
) {
console.log('Lock exists, retrying...');
// Retry if a lock causes the git process to fail
await sleep(300);
let retries = 5;
while (retries > 0) {
// eslint-disable-next-line no-await-in-loop
const result = await spawnTerminal({
command,
dir,
mainWindow,
});
console.log({ result });
if (result.returnCode === 0) {
break;
} else {
return result.returnCode;
// eslint-disable-next-line no-lonely-if
if (
result.out?.includes(
'Another git process seems to be running in this repository',
)
) {
retries--;
console.log(
`Lock exists, retrying... (${retries} remaining)`,
);
// Retry if a lock causes the git process to fail
// eslint-disable-next-line no-await-in-loop
await sleep(300);
} else {
return result.returnCode;
}
}
}

// eslint-disable-next-line no-await-in-loop
await reloadGitTree({ mainWindow });
}

Expand Down

0 comments on commit 3e32dac

Please sign in to comment.