diff --git a/lib/workers/branch/commit.js b/lib/workers/branch/commit.js index e00460011ae9953a14321f22233dbab69ecb68b5..865de55430108ba6a36770b28ab64eb4730344ef 100644 --- a/lib/workers/branch/commit.js +++ b/lib/workers/branch/commit.js @@ -13,7 +13,9 @@ async function commitFilesToBranch(config) { logger.debug(`${updatedFiles.length} file(s) to commit`); let commitMessage = handlebars.compile(config.commitMessage)(config); if (config.semanticCommits) { - commitMessage = `${config.semanticPrefix} ${commitMessage.toLowerCase()}`; + const splitMessage = commitMessage.split('\n'); + splitMessage[0] = splitMessage[0].toLowerCase(); + commitMessage = `${config.semanticPrefix} ${splitMessage.join('\n')}`; } // API will know whether to create new branch or not await config.api.commitFilesToBranch( diff --git a/test/workers/branch/commit.spec.js b/test/workers/branch/commit.spec.js index 27bc9d5b6140eb744b95c5ba6d4e5019b1be823d..0e397186f097bde5c3ed6aeb606f37e639c72ae3 100644 --- a/test/workers/branch/commit.spec.js +++ b/test/workers/branch/commit.spec.js @@ -41,5 +41,18 @@ describe('workers/branch/automerge', () => { expect(config.api.commitFilesToBranch.mock.calls.length).toBe(1); expect(config.api.commitFilesToBranch.mock.calls).toMatchSnapshot(); }); + it('lowercases only the first line when applying semantic prefix', async () => { + config.updatedPackageFiles.push({ + name: 'package.json', + contents: 'some contents', + }); + config.commitMessage = 'Foo\n\nBar'; + config.semanticCommits = true; + await commitFilesToBranch(config); + expect(config.api.commitFilesToBranch.mock.calls.length).toBe(1); + expect(config.api.commitFilesToBranch.mock.calls[0][2]).toEqual( + 'some-prefix foo\n\nBar' + ); + }); }); });