Skip to content

Commit 0911cae

Browse files
committedAug 20, 2020
fix: action shows error ouput when not all commits have warnings
Fixes #43
1 parent e93ddf0 commit 0911cae

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed
 

‎src/action.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,8 @@ const formatErrors = lintedCommits =>
104104

105105
const hasOnlyWarnings = lintedCommits =>
106106
lintedCommits.length &&
107-
lintedCommits.every(
108-
({ lintResult }) => lintResult.valid && lintResult.warnings.length,
109-
)
107+
lintedCommits.every(({ lintResult }) => lintResult.valid) &&
108+
lintedCommits.some(({ lintResult }) => lintResult.warnings.length)
110109

111110
const setFailed = formattedResults => {
112111
core.setFailed(`You have commit messages with errors\n\n${formattedResults}`)

‎src/action.test.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,14 @@ describe('Commit Linter action', () => {
400400

401401
beforeEach(async () => {
402402
cwd = await git.bootstrap('fixtures/conventional')
403+
await gitEmptyCommit(cwd, 'chore: previous commit')
404+
await gitEmptyCommit(cwd, 'chore: correct message with no warnings')
403405
await gitEmptyCommit(
404406
cwd,
405407
'chore: correct message\nsome context without leading blank line',
406408
)
407-
const [to] = await getCommitHashes(cwd)
408-
await createPushEventPayload(cwd, { to })
409+
const [before, from, to] = await getCommitHashes(cwd)
410+
await createPushEventPayload(cwd, { before, to })
409411
updatePushEnvVars(cwd, to)
410412
td.replace(process, 'cwd', () => cwd)
411413
td.replace(console, 'log')
@@ -419,6 +421,13 @@ describe('Commit Linter action', () => {
419421
errors: [],
420422
warnings: ['body must have leading blank line'],
421423
},
424+
{
425+
hash: from,
426+
message: 'chore: correct message with no warnings',
427+
valid: true,
428+
errors: [],
429+
warnings: [],
430+
},
422431
]
423432
})
424433

0 commit comments

Comments
 (0)
Please sign in to comment.