Skip to content

Commit

Permalink
fix(plugin-release): avoid git concurrency issues when running with w…
Browse files Browse the repository at this point in the history
…orkspaces foreach
  • Loading branch information
kherock committed Jul 27, 2023
1 parent 9961868 commit 5b8c6fb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/plugin-release/sources/releaseUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,25 @@ async function loadConventionalChangelogPreset(require: presetLoader.RequireMeth
}
}

let lastGitTask: Promise<unknown> | undefined;

/** lifted from gitUtils in @yarnpkg/plugin-git */
export async function git(message: string, args: Array<string>, opts: Omit<execUtils.ExecvpOptions, 'strict'>, {configuration}: {configuration: Configuration}) {
export async function git(message: string, args: Array<string>, opts: Omit<execUtils.ExecvpOptions, 'strict'>, {configuration}: { configuration: Configuration }) {
// avoid concurrency issues when running with workspaces foreach
try {
return await execUtils.execvp(`git`, args, {
await lastGitTask;
} catch {
// do nothing
} finally {
lastGitTask = undefined;
}
try {
lastGitTask = execUtils.execvp(`git`, args, {
...opts,
// The promise won't reject on non-zero exit codes unless we pass the strict option.
strict: true,
});
return await lastGitTask;
} catch (error) {
if (!(error instanceof execUtils.ExecError))
throw error;
Expand Down

0 comments on commit 5b8c6fb

Please sign in to comment.