Skip to content

Commit 1607ac7

Browse files
committed
fix: execute git config commands synchronously
this fixes the following error I was running into: error: could not lock config file .git/config: File exists
1 parent acd95e2 commit 1607ac7

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/helpers/git.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,18 @@ module.exports = new (class Git {
3131
}
3232
}
3333

34-
// Set config
35-
this.config('user.name', gitUserName)
36-
this.config('user.email', gitUserEmail)
37-
38-
// Update the origin
39-
if (githubToken) {
40-
this.updateOrigin(`https://x-access-token:${githubToken}@${gitUrl}/${GITHUB_REPOSITORY}.git`)
41-
}
34+
// use a self-invoking async function to await promises inside a constructor
35+
// this avoids git config lock errors which are triggered when multiple `git config` commands are run
36+
(async () => {
37+
// Set config
38+
await this.config('user.name', gitUserName)
39+
await this.config('user.email', gitUserEmail)
40+
41+
// Update the origin
42+
if (githubToken) {
43+
await this.updateOrigin(`https://x-access-token:${githubToken}@${gitUrl}/${GITHUB_REPOSITORY}.git`)
44+
}
45+
})()
4246
}
4347

4448
/**

0 commit comments

Comments
 (0)