diff --git a/lib/config/types.ts b/lib/config/types.ts index 777f27b3aa0a00..9f3a6d46f85879 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -208,6 +208,7 @@ export interface RenovateConfig Record { 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 e58bd7aec5ef1b..db9b3b8ddf75a4 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: '', + }); + 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: `, + 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 e90459e3100c8b..708d82cc33f167 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, });