5
0
Fork 0
mirror of https://github.com/wagoid/commitlint-github-action.git synced 2025-11-07 08:06:54 +00:00

fix: use helpUrl from config when present

Fixes #234
This commit is contained in:
wagoid 2021-10-11 15:27:08 -03:00
parent a5ab401c4d
commit 6f0b49bb7b
3 changed files with 35 additions and 3 deletions

View file

@ -0,0 +1,4 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
helpUrl: 'https://example.org',
}

View file

@ -91,12 +91,12 @@ function getOptsFromConfig(config) {
} }
} }
const formatErrors = (lintedCommits) => const formatErrors = (lintedCommits, { config }) =>
format( format(
{ results: lintedCommits.map((commit) => commit.lintResult) }, { results: lintedCommits.map((commit) => commit.lintResult) },
{ {
color: true, color: true,
helpUrl: getInput('helpURL'), helpUrl: config.helpUrl || getInput('helpURL'),
}, },
) )
@ -129,7 +129,7 @@ const showLintResults = async ([from, to]) => {
hash: commit.hash, hash: commit.hash,
})), })),
) )
const formattedResults = formatErrors(lintedCommits) const formattedResults = formatErrors(lintedCommits, { config })
generateOutputs(lintedCommits) generateOutputs(lintedCommits)

View file

@ -76,6 +76,13 @@ describe('Commit Linter action', () => {
await runAction() await runAction()
td.verify(core.setFailed(contains('You have commit messages with errors'))) td.verify(core.setFailed(contains('You have commit messages with errors')))
td.verify(
core.setFailed(
contains(
'https://github.com/conventional-changelog/commitlint/#what-is-commitlint',
),
),
)
}) })
it('should fail for single push with incorrect message', async () => { it('should fail for single push with incorrect message', async () => {
@ -577,4 +584,25 @@ describe('Commit Linter action', () => {
td.verify(console.log('Lint free! 🎉')) td.verify(console.log('Lint free! 🎉'))
}) })
}) })
describe('when a different helpUrl is provided in the config', () => {
beforeEach(async () => {
cwd = await git.bootstrap('fixtures/custom-help-url')
await gitEmptyCommit(cwd, 'wrong message')
const [to] = await getCommitHashes(cwd)
await createPushEventPayload(cwd, { to })
updatePushEnvVars(cwd, to)
td.replace(process, 'cwd', () => cwd)
td.replace(console, 'log')
})
it('should show custom URL from helpUrl', async () => {
await runAction()
td.verify(
core.setFailed(contains('You have commit messages with errors')),
)
td.verify(core.setFailed(contains(' https://example.org')))
})
})
}) })