diff --git a/lib/gitWorkflow.js b/lib/gitWorkflow.js index 2d2822dcd..56f3d2b0d 100644 --- a/lib/gitWorkflow.js +++ b/lib/gitWorkflow.js @@ -235,11 +235,12 @@ class GitWorkflow { */ async applyModifications(ctx) { debug('Adding task modifications to index...') - await Promise.all( - // stagedFileChunks includes staged files that lint-staged originally detected. - // Add only these files so any 3rd-party edits to other files won't be included in the commit. - this.stagedFileChunks.map(stagedFiles => this.execGit(['add', '--', ...stagedFiles])) - ) + // stagedFileChunks includes staged files that lint-staged originally detected. + // Add only these files so any 3rd-party edits to other files won't be included in the commit. + // This is run "serially" to prevent race conditions because `git add` is a locking operation. + for (const stagedFiles of this.stagedFileChunks) { + await this.execGit(['add', '--', ...stagedFiles]) + } debug('Done adding task modifications to index!') const stagedFilesAfterAdd = await this.execGit(['diff', '--name-only', '--cached'])