diff --git a/docs/configuration.md b/docs/configuration.md index 367176031eb8ec46b2683ce5611b1096bb897a4f..cf19814abf1bcecef27768612e137958c8e623a0 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 8ed29d400c64ecc26e79260f1d11ab85705f00da..180f517f5f0525f44e037d15c10c0f79ea9b4562 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 634d99bb83d44c8501cd1c76578d6a422e7ad7d3..bce9d94d3a017096f5ee1e9357a0f72644633404 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 300719fe143d13bf7a3c21d8c264d882ed59f412..cb12267eed42c8bf2114412c1c1b9ab9aefc3552 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 80be3f08629dd5d23d1f8fe4186d6e032842300e..85791623752ad8a93dc7ae7f54f4656f153765a2 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(); + }); }); });