From 2720688f4cbb52315d971b2637f83e4a9484bf2c Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Mon, 25 Dec 2017 20:37:14 +0100
Subject: [PATCH] feat: commit body
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This PR adds the configuration option “commitMessageBody”. The contents of this will be appended to the commitMessage, separated by two line returns.
---
 docs/configuration.md                         |  8 ++++++++
 lib/config/definitions.js                     |  7 +++++++
 lib/workers/branch/commit.js                  |  5 +++++
 .../branch/__snapshots__/commit.spec.js.snap  | 20 +++++++++++++++++++
 test/workers/branch/commit.spec.js            | 10 ++++++++++
 5 files changed, 50 insertions(+)

diff --git a/docs/configuration.md b/docs/configuration.md
index 367176031e..cf19814abf 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -645,6 +645,14 @@ location with this method.
   <td>`RENOVATE_COMMIT_MESSAGE`</td>
   <td><td>
 </tr>
+<tr>
+  <td>`commitBody`</td>
+  <td>Commit message body template. Will be appended to commit message, separated by two line returns.</td>
+  <td>string</td>
+  <td><pre>null</pre></td>
+  <td>`RENOVATE_COMMIT_BODY`</td>
+  <td><td>
+</tr>
 <tr>
   <td>`prTitle`</td>
   <td>Pull Request title template</td>
diff --git a/lib/config/definitions.js b/lib/config/definitions.js
index 8ed29d400c..180f517f5f 100644
--- a/lib/config/definitions.js
+++ b/lib/config/definitions.js
@@ -536,6 +536,13 @@ const options = [
     default: template('commitMessage'),
     cli: false,
   },
+  {
+    name: 'commitBody',
+    description:
+      'Commit message body template. Will be appended to commit message, separated by two line returns.',
+    type: 'string',
+    cli: false,
+  },
   {
     name: 'prTitle',
     description: 'Pull Request title template',
diff --git a/lib/workers/branch/commit.js b/lib/workers/branch/commit.js
index 634d99bb83..bce9d94d3a 100644
--- a/lib/workers/branch/commit.js
+++ b/lib/workers/branch/commit.js
@@ -20,6 +20,11 @@ async function commitFilesToBranch(config) {
       }
       commitMessage = `${semanticPrefix}: ${splitMessage.join('\n')}`;
     }
+    if (config.commitBody) {
+      commitMessage = `${commitMessage}\n\n${handlebars.compile(
+        config.commitBody
+      )(config)}`;
+    }
     // API will know whether to create new branch or not
     await platform.commitFilesToBranch(
       config.branchName,
diff --git a/test/workers/branch/__snapshots__/commit.spec.js.snap b/test/workers/branch/__snapshots__/commit.spec.js.snap
index 300719fe14..cb12267eed 100644
--- a/test/workers/branch/__snapshots__/commit.spec.js.snap
+++ b/test/workers/branch/__snapshots__/commit.spec.js.snap
@@ -1,5 +1,25 @@
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
+exports[`workers/branch/automerge commitFilesToBranch adds commit message body 1`] = `
+Array [
+  Array [
+    "renovate/some-branch",
+    Array [
+      Object {
+        "contents": "some contents",
+        "name": "package.json",
+      },
+    ],
+    "some commit message
+
+[skip-ci]",
+    undefined,
+    null,
+    null,
+  ],
+]
+`;
+
 exports[`workers/branch/automerge commitFilesToBranch applies semantic prefix 1`] = `
 Array [
   Array [
diff --git a/test/workers/branch/commit.spec.js b/test/workers/branch/commit.spec.js
index 80be3f0862..8579162375 100644
--- a/test/workers/branch/commit.spec.js
+++ b/test/workers/branch/commit.spec.js
@@ -53,5 +53,15 @@ describe('workers/branch/automerge', () => {
         'a(b): foo\n\nBar'
       );
     });
+    it('adds commit message body', async () => {
+      config.updatedPackageFiles.push({
+        name: 'package.json',
+        contents: 'some contents',
+      });
+      config.commitBody = '[skip-ci]';
+      await commitFilesToBranch(config);
+      expect(platform.commitFilesToBranch.mock.calls.length).toBe(1);
+      expect(platform.commitFilesToBranch.mock.calls).toMatchSnapshot();
+    });
   });
 });
-- 
GitLab