Skip to content

Commit

Permalink
Merge pull request #213 from iloveitaly/sync-git-config
Browse files Browse the repository at this point in the history
fix: execute git config commands synchronously
  • Loading branch information
TriPSs committed May 18, 2023
2 parents acd95e2 + bbae947 commit d479ae2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/helpers/git.js
Expand Up @@ -14,30 +14,33 @@ module.exports = new (class Git {
// Make the Github token secret
core.setSecret(githubToken)

const gitUserName = core.getInput('git-user-name')
const gitUserEmail = core.getInput('git-user-email')
const gitUrl = core.getInput('git-url')

// if the env is dont-use-git then we mock exec as we are testing a workflow
if (ENV === 'dont-use-git') {
this.exec = (command) => {
const fullCommand = `git ${command}`

console.log(`Skipping "${fullCommand}" because of test env`)

if (!fullCommand.includes('git remote set-url origin')) {
this.commandsRun.push(fullCommand)
}
}
}
}

init = async () => {
const gitUserName = core.getInput('git-user-name')
const gitUserEmail = core.getInput('git-user-email')
const gitUrl = core.getInput('git-url')
const githubToken = core.getInput('github-token')

// Set config
this.config('user.name', gitUserName)
this.config('user.email', gitUserEmail)
await this.config('user.name', gitUserName)
await this.config('user.email', gitUserEmail)

// Update the origin
if (githubToken) {
this.updateOrigin(`https://x-access-token:${githubToken}@${gitUrl}/${GITHUB_REPOSITORY}.git`)
await this.updateOrigin(`https://x-access-token:${githubToken}@${gitUrl}/${GITHUB_REPOSITORY}.git`)
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Expand Up @@ -79,6 +79,8 @@ async function run() {
core.info(`Skipping empty releases is "${skipEmptyRelease ? 'enabled' : 'disabled'}"`)
core.info(`Skipping the update of the version file is "${skipVersionFile ? 'enabled' : 'disabled'}"`)

await git.init()

if (!skipGitPull) {
core.info('Pull to make sure we have the full git history')
await git.pull()
Expand Down

0 comments on commit d479ae2

Please sign in to comment.