From e5654fc81208cac0bf922a6924662802eb88c93f Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@keylocation.sg>
Date: Thu, 7 Sep 2017 21:18:50 +0200
Subject: [PATCH] fix: convert only first line of commit message to lowercase
 (#779)

Helps #777
---
 lib/workers/branch/commit.js       |  4 +++-
 test/workers/branch/commit.spec.js | 13 +++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/lib/workers/branch/commit.js b/lib/workers/branch/commit.js
index e00460011a..865de55430 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 27bc9d5b61..0e397186f0 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'
+      );
+    });
   });
 });
-- 
GitLab