From 961b6d4cd7565e86ea5e28bcb015042ae2022f4f Mon Sep 17 00:00:00 2001 From: wagoid <7467450+wagoid@users.noreply.github.com> Date: Sat, 11 Sep 2021 08:22:56 -0300 Subject: [PATCH] fix: action failing to check footer of a single commit Fixes #187 --- fixtures/signed-off-by/commitlint.config.js | 6 ++++++ src/action.test.js | 7 ++++--- src/gitCommits.js | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 fixtures/signed-off-by/commitlint.config.js diff --git a/fixtures/signed-off-by/commitlint.config.js b/fixtures/signed-off-by/commitlint.config.js new file mode 100644 index 0000000..09a2168 --- /dev/null +++ b/fixtures/signed-off-by/commitlint.config.js @@ -0,0 +1,6 @@ +module.exports = { + extends: ['@commitlint/config-conventional'], + rules: { + 'signed-off-by': [2, 'always', 'Signed-off-by:'], + }, +} diff --git a/src/action.test.js b/src/action.test.js index 1673086..35e34f6 100644 --- a/src/action.test.js +++ b/src/action.test.js @@ -1,5 +1,6 @@ /* eslint-env jest */ import { git } from '@commitlint/test' +import { describe } from '@jest/globals' import execa from 'execa' import td from 'testdouble' import { @@ -555,12 +556,12 @@ describe('Commit Linter action', () => { }) }) - describe('when commit contains signed-off-by message', () => { + describe('when commit contains required signed-off-by message', () => { beforeEach(async () => { - cwd = await git.bootstrap('fixtures/conventional') + cwd = await git.bootstrap('fixtures/signed-off-by') await gitEmptyCommit( cwd, - 'chore: correct message\n\nsome context without leading blank line\nSigned-off-by: John Doe ', + 'chore: correct message\n\nsome context without leading blank line.\n\nSigned-off-by: John Doe ', ) const [to] = await getCommitHashes(cwd) await createPushEventPayload(cwd, { to }) diff --git a/src/gitCommits.js b/src/gitCommits.js index 3298a63..5e0ab0e 100644 --- a/src/gitCommits.js +++ b/src/gitCommits.js @@ -33,7 +33,7 @@ const gitCommits = async (gitOpts) => { return { hash, - message, + message: message.replace(commitDelimiter, ''), } })