mirror of
https://github.com/wagoid/commitlint-github-action.git
synced 2025-11-07 16:06:56 +00:00
Merge pull request #44 from wagoid/fix/action-showing-error-output-when-not-all-commits-have-warnings
fix: action shows error ouput when not all commits have warnings
This commit is contained in:
commit
34cc85312e
2 changed files with 13 additions and 5 deletions
|
|
@ -104,9 +104,8 @@ const formatErrors = lintedCommits =>
|
||||||
|
|
||||||
const hasOnlyWarnings = lintedCommits =>
|
const hasOnlyWarnings = lintedCommits =>
|
||||||
lintedCommits.length &&
|
lintedCommits.length &&
|
||||||
lintedCommits.every(
|
lintedCommits.every(({ lintResult }) => lintResult.valid) &&
|
||||||
({ lintResult }) => lintResult.valid && lintResult.warnings.length,
|
lintedCommits.some(({ lintResult }) => lintResult.warnings.length)
|
||||||
)
|
|
||||||
|
|
||||||
const setFailed = formattedResults => {
|
const setFailed = formattedResults => {
|
||||||
core.setFailed(`You have commit messages with errors\n\n${formattedResults}`)
|
core.setFailed(`You have commit messages with errors\n\n${formattedResults}`)
|
||||||
|
|
|
||||||
|
|
@ -400,12 +400,14 @@ describe('Commit Linter action', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
cwd = await git.bootstrap('fixtures/conventional')
|
cwd = await git.bootstrap('fixtures/conventional')
|
||||||
|
await gitEmptyCommit(cwd, 'chore: previous commit')
|
||||||
|
await gitEmptyCommit(cwd, 'chore: correct message with no warnings')
|
||||||
await gitEmptyCommit(
|
await gitEmptyCommit(
|
||||||
cwd,
|
cwd,
|
||||||
'chore: correct message\nsome context without leading blank line',
|
'chore: correct message\nsome context without leading blank line',
|
||||||
)
|
)
|
||||||
const [to] = await getCommitHashes(cwd)
|
const [before, from, to] = await getCommitHashes(cwd)
|
||||||
await createPushEventPayload(cwd, { to })
|
await createPushEventPayload(cwd, { before, to })
|
||||||
updatePushEnvVars(cwd, to)
|
updatePushEnvVars(cwd, to)
|
||||||
td.replace(process, 'cwd', () => cwd)
|
td.replace(process, 'cwd', () => cwd)
|
||||||
td.replace(console, 'log')
|
td.replace(console, 'log')
|
||||||
|
|
@ -419,6 +421,13 @@ describe('Commit Linter action', () => {
|
||||||
errors: [],
|
errors: [],
|
||||||
warnings: ['body must have leading blank line'],
|
warnings: ['body must have leading blank line'],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
hash: from,
|
||||||
|
message: 'chore: correct message with no warnings',
|
||||||
|
valid: true,
|
||||||
|
errors: [],
|
||||||
|
warnings: [],
|
||||||
|
},
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue