Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: prHeader and prFooter #6511

Merged
merged 3 commits into from
Jun 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,10 @@ This setting tells Renovate when you would like it to raise PRs:

Renovate defaults to `immediate` but some like to change to `not-pending`. If you configure to immediate, it means you will usually get GitHub notifications that a new PR is available but if you view it immediately then it will still have "pending" tests so you can't take any action. With `not-pending`, it means that when you receive the PR notification, you can see if it passed or failed and take action immediately. Therefore you can customise this setting if you wish to be notified a little later in order to reduce "noise".

## prFooter

## prHeader

## prHourlyLimit

This setting - if enabled - helps slow down Renovate, particularly during the onboarding phase. What may happen without this setting is:
Expand Down
2 changes: 0 additions & 2 deletions docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ Set this to true if you wish for Renovate to persist repo data between runs. The

Parameter to reduce CI load. CI jobs are usually triggered by these events: pull-request creation, pull-request update, automerge events. Set as an integer. Default is no limit.

## prFooter

## printConfig

This option is useful for troubleshooting, particularly if using presets. e.g. run `renovate foo/bar --print-config > config.log` and the fully-resolved config will be included in the log file.
Expand Down
9 changes: 7 additions & 2 deletions lib/config/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1269,12 +1269,17 @@ const options: RenovateOptions[] = [
default: null,
cli: false,
},
{
name: 'prHeader',
description: 'Any text added here will be placed first in the PR body.',
type: 'string',
},
{
name: 'prFooter',
description: 'Pull Request footer template',
description:
'Any text added here will be placed last in the PR body, with a divider separator before it.',
type: 'string',
default: `This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).`,
stage: 'global',
},
{
name: 'lockFileMaintenance',
Expand Down
2 changes: 1 addition & 1 deletion lib/config/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('config/index', () => {
);
expect(parsedConfig).toContainEntries([
['token', 'abc'],
['global', { prFooter: 'custom' }],
['prFooter', 'custom'],
['logContext', 'abc123'],
['customPrFooter', true],
]);
Expand Down
6 changes: 0 additions & 6 deletions lib/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,6 @@ export async function parseConfigs(
delete config.logFileLevel;

// Move global variables that we need to use later
const importGlobals = ['prBanner', 'prFooter'];
config.global = {};
importGlobals.forEach((key) => {
config.global[key] = config[key];
delete config[key];
});
global.trustLevel =
config.trustLevel || /* istanbul ignore next: never happen? */ 'low';
delete config.trustLevel;
Expand Down
1 change: 0 additions & 1 deletion lib/config/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export async function validateConfig(
function isIgnored(key: string): boolean {
const ignoredNodes = [
'$schema',
'prBanner',
'depType',
'npmToken',
'packageFile',
Expand Down
3 changes: 2 additions & 1 deletion lib/workers/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export interface BranchUpgradeConfig
packageFile?: string;

reuseExistingBranch?: boolean;
prBanner?: string;
prHeader?: string;
prFooter?: string;
prBodyNotes?: string[];
prBodyTemplate?: string;
prPriority?: number;
Expand Down
14 changes: 7 additions & 7 deletions lib/workers/pr/__snapshots__/index.spec.ts.snap

Large diffs are not rendered by default.

16 changes: 0 additions & 16 deletions lib/workers/pr/body/banner.ts

This file was deleted.

4 changes: 2 additions & 2 deletions lib/workers/pr/body/footer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { BranchConfig } from '../../common';

// istanbul ignore next
export function getPrFooter(config: BranchConfig): string {
if (config.global && config.global.prFooter) {
return '\n---\n\n' + template.compile(config.global.prFooter, config);
if (config.prFooter) {
return '\n---\n\n' + template.compile(config.prFooter, config);
}
return '';
}
10 changes: 10 additions & 0 deletions lib/workers/pr/body/header.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as template from '../../../util/template';
import { BranchConfig } from '../../common';

// istanbul ignore next
export function getPrHeader(config: BranchConfig): string {
if (!config.prHeader) {
return '';
}
return template.compile(config.prHeader, config) + '\n\n';
}
6 changes: 3 additions & 3 deletions lib/workers/pr/body/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { platform } from '../../../platform';
import * as template from '../../../util/template';
import { get } from '../../../versioning';
import { BranchConfig } from '../../common';
import { getPrBanner } from './banner';
import { getChangelogs } from './changelogs';
import { getPrConfigDescription } from './config-description';
import { getControls } from './controls';
import { getPrFooter } from './footer';
import { getPrHeader } from './header';
import { getPrExtraNotes, getPrNotes } from './notes';
import { getPrUpdatesTable } from './updates-table';

Expand Down Expand Up @@ -67,7 +67,7 @@ function massageUpdateMetadata(config: BranchConfig): void {
export async function getPrBody(config: BranchConfig): Promise<string> {
massageUpdateMetadata(config);
const content = {
banner: getPrBanner(config),
header: getPrHeader(config),
table: getPrUpdatesTable(config),
notes: getPrNotes(config) + getPrExtraNotes(config),
changelogs: getChangelogs(config),
Expand All @@ -76,7 +76,7 @@ export async function getPrBody(config: BranchConfig): Promise<string> {
footer: getPrFooter(config),
};
const defaultPrBodyTemplate =
'{{{banner}}}{{{table}}}{{{notes}}}{{{changelogs}}}{{{configDescription}}}{{{controls}}}{{{footer}}}';
'{{{header}}}{{{table}}}{{{notes}}}{{{changelogs}}}{{{configDescription}}}{{{controls}}}{{{footer}}}';
const prBodyTemplate = config.prBodyTemplate || defaultPrBodyTemplate;
let prBody = template.compile(prBodyTemplate, content, false);
prBody = prBody.trim();
Expand Down
1 change: 0 additions & 1 deletion lib/workers/repository/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export async function initRepo(input: RenovateConfig): Promise<RenovateConfig> {
warnings: [],
branchList: [],
};
config.global = config.global || {};
config = await initApis(config);
config.semanticCommits = await detectSemanticCommits(config);
config.baseBranchSha = await platform.setBaseBranch(config.baseBranch);
Expand Down
13 changes: 6 additions & 7 deletions lib/workers/repository/onboarding/pr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,12 @@ If you need any further assistance then you can also [request help here](${confi
prBody = prBody.replace('{{BASEBRANCH}}\n', getBaseBranchDesc(config));
prBody = prBody.replace('{{PRLIST}}\n', getPrList(config, branches));
// istanbul ignore if
if (config.global) {
if (config.global.prBanner) {
prBody = config.global.prBanner + '\n\n' + prBody;
}
if (config.global.prFooter) {
prBody = prBody + '\n---\n\n' + config.global.prFooter + '\n';
}
if (config.prHeader) {
prBody = (config.prHeader || '') + '\n\n' + prBody;
}
// istanbul ignore if
if (config.prFooter) {
prBody = prBody + '\n---\n\n' + config.prFooter + '\n';
}
logger.trace('prBody:\n' + prBody);

Expand Down