Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use helpUrl from config when present #259

Merged
merged 1 commit into from Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions fixtures/custom-help-url/commitlint.config.js
@@ -0,0 +1,4 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
helpUrl: 'https://example.org',
}
6 changes: 3 additions & 3 deletions src/action.js
Expand Up @@ -91,12 +91,12 @@ function getOptsFromConfig(config) {
}
}

const formatErrors = (lintedCommits) =>
const formatErrors = (lintedCommits, { config }) =>
format(
{ results: lintedCommits.map((commit) => commit.lintResult) },
{
color: true,
helpUrl: getInput('helpURL'),
helpUrl: config.helpUrl || getInput('helpURL'),
},
)

Expand Down Expand Up @@ -129,7 +129,7 @@ const showLintResults = async ([from, to]) => {
hash: commit.hash,
})),
)
const formattedResults = formatErrors(lintedCommits)
const formattedResults = formatErrors(lintedCommits, { config })

generateOutputs(lintedCommits)

Expand Down
28 changes: 28 additions & 0 deletions src/action.test.js
Expand Up @@ -76,6 +76,13 @@ describe('Commit Linter action', () => {
await runAction()

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 () => {
Expand Down Expand Up @@ -577,4 +584,25 @@ describe('Commit Linter action', () => {
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')))
})
})
})