diff --git a/lib/config/types.ts b/lib/config/types.ts index 777f27b3aa0a000350e246207916afa28e93f6b9..9f3a6d46f858794dd127879683f2ae2c99562694 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -208,6 +208,7 @@ export interface RenovateConfig Record<string, unknown> { depName?: string; baseBranches?: string[]; + commitBody?: string; useBaseBranchConfig?: UseBaseBranchConfigType; baseBranch?: string; defaultBranch?: string; diff --git a/lib/workers/repository/onboarding/branch/create.spec.ts b/lib/workers/repository/onboarding/branch/create.spec.ts index e58bd7aec5ef1b0c002aa09e221b9ee368452d71..db9b3b8ddf75a4c9b92d42603471c64024eedc13 100644 --- a/lib/workers/repository/onboarding/branch/create.spec.ts +++ b/lib/workers/repository/onboarding/branch/create.spec.ts @@ -57,6 +57,54 @@ describe('workers/repository/onboarding/branch/create', () => { }); }); + describe('applies the commitBody value', () => { + it('to the default commit message', async () => { + await createOnboardingBranch({ + ...config, + commitBody: 'some commit body', + }); + expect(scm.commitAndPush).toHaveBeenCalledWith({ + branchName: 'renovate/configure', + files: [ + { + type: 'addition', + path: 'renovate.json', + contents: '{"foo":"bar"}', + }, + ], + force: true, + message: `Add renovate.json\n\nsome commit body`, + platformCommit: false, + }); + }); + + it('to the supplied commit message', async () => { + const message = + 'We can Renovate if we want to, we can leave PRs in decline'; + + config.onboardingCommitMessage = message; + + await createOnboardingBranch({ + ...config, + commitBody: 'Signed Off: {{{gitAuthor}}}', + gitAuthor: '<Bot bot@botland.com>', + }); + expect(scm.commitAndPush).toHaveBeenCalledWith({ + branchName: 'renovate/configure', + files: [ + { + type: 'addition', + path: 'renovate.json', + contents: '{"foo":"bar"}', + }, + ], + force: true, + message: `We can Renovate if we want to, we can leave PRs in decline\n\nSigned Off: <Bot bot@botland.com>`, + platformCommit: false, + }); + }); + }); + describe('applies the commitMessagePrefix value', () => { it('to the default commit message', async () => { const prefix = 'RENOV-123'; diff --git a/lib/workers/repository/onboarding/branch/create.ts b/lib/workers/repository/onboarding/branch/create.ts index e90459e3100c8bbf5d43fcfb4620123c58cca251..708d82cc33f1674827f5e03605a9f2a84349f05e 100644 --- a/lib/workers/repository/onboarding/branch/create.ts +++ b/lib/workers/repository/onboarding/branch/create.ts @@ -3,6 +3,7 @@ import { GlobalConfig } from '../../../../config/global'; import type { RenovateConfig } from '../../../../config/types'; import { logger } from '../../../../logger'; import { scm } from '../../../../modules/platform/scm'; +import { compile } from '../../../../util/template'; import { OnboardingCommitMessageFactory } from './commit-message'; import { getOnboardingConfigContents } from './config'; @@ -25,7 +26,17 @@ export async function createOnboardingBranch( config, configFile!, ); - const commitMessage = commitMessageFactory.create(); + let commitMessage = commitMessageFactory.create().toString(); + + if (config.commitBody) { + commitMessage = `${commitMessage}\n\n${compile( + config.commitBody, + // only allow gitAuthor template value in the commitBody + { gitAuthor: config.gitAuthor }, + )}`; + + logger.trace(`commitMessage: ${commitMessage}`); + } // istanbul ignore if if (GlobalConfig.get('dryRun')) { @@ -44,7 +55,7 @@ export async function createOnboardingBranch( contents, }, ], - message: commitMessage.toString(), + message: commitMessage, platformCommit: !!config.platformCommit, force: true, });