mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
refactor: move pr config description to separate file
This commit is contained in:
parent
021e060d73
commit
002db29e58
2 changed files with 67 additions and 56 deletions
64
lib/workers/pr/pr-body-config.js
Normal file
64
lib/workers/pr/pr-body-config.js
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
const { appName, urls } = require('../../config/app-strings');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
getPrConfigDescription,
|
||||||
|
};
|
||||||
|
|
||||||
|
async function getPrConfigDescription(config) {
|
||||||
|
let prBody = `\n\n---\n\n### ${appName} configuration\n\n`;
|
||||||
|
prBody += `:date: **Schedule**: `;
|
||||||
|
if (
|
||||||
|
config.schedule &&
|
||||||
|
config.schedule !== 'at any time' &&
|
||||||
|
config.schedule[0] !== 'at any time'
|
||||||
|
) {
|
||||||
|
prBody += `"${config.schedule}"`;
|
||||||
|
if (config.timezone) {
|
||||||
|
prBody += ` in timezone ${config.timezone}.`;
|
||||||
|
} else {
|
||||||
|
prBody += ` (UTC).`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
prBody += 'At any time (no schedule defined).';
|
||||||
|
}
|
||||||
|
|
||||||
|
prBody += '\n\n';
|
||||||
|
prBody += ':vertical_traffic_light: **Automerge**: ';
|
||||||
|
if (config.automerge) {
|
||||||
|
const branchStatus = await platform.getBranchStatus(
|
||||||
|
config.branchName,
|
||||||
|
config.requiredStatusChecks
|
||||||
|
);
|
||||||
|
// istanbul ignore if
|
||||||
|
if (branchStatus === 'failed') {
|
||||||
|
prBody += 'Disabled due to failing status checks.';
|
||||||
|
} else {
|
||||||
|
prBody += 'Enabled.';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
prBody +=
|
||||||
|
'Disabled by config. Please merge this manually once you are satisfied.';
|
||||||
|
}
|
||||||
|
prBody += '\n\n';
|
||||||
|
prBody += ':recycle: **Rebasing**: ';
|
||||||
|
if (config.rebaseStalePrs) {
|
||||||
|
prBody += 'Whenever PR is stale';
|
||||||
|
} else {
|
||||||
|
prBody += 'Whenever PR becomes conflicted';
|
||||||
|
}
|
||||||
|
if (config.platform === 'github') {
|
||||||
|
prBody += `, or if you modify the PR title to begin with "\`rebase!\`".\n\n`;
|
||||||
|
} else {
|
||||||
|
prBody += '.\n\n';
|
||||||
|
}
|
||||||
|
if (config.recreateClosed) {
|
||||||
|
prBody += `:ghost: **Immortal**: This PR will be recreated if closed unmerged. Get [config help](${
|
||||||
|
urls.help
|
||||||
|
}) if that's undesired.\n\n`;
|
||||||
|
} else {
|
||||||
|
prBody += `:no_bell: **Ignore**: Close this PR and you won't be reminded about ${
|
||||||
|
config.upgrades.length === 1 ? 'this update' : 'these updates'
|
||||||
|
} again.\n\n`;
|
||||||
|
}
|
||||||
|
return prBody;
|
||||||
|
}
|
|
@ -1,10 +1,11 @@
|
||||||
const is = require('@sindresorhus/is');
|
const is = require('@sindresorhus/is');
|
||||||
const handlebars = require('handlebars');
|
const handlebars = require('handlebars');
|
||||||
const releaseNotesHbs = require('./changelog/hbs-template');
|
const releaseNotesHbs = require('./changelog/hbs-template');
|
||||||
|
const { getPrConfigDescription } = require('./pr-body-config');
|
||||||
|
|
||||||
const versioning = require('../../versioning');
|
const versioning = require('../../versioning');
|
||||||
|
|
||||||
const { appName, appSlug, urls } = require('../../config/app-strings');
|
const { appName, appSlug } = require('../../config/app-strings');
|
||||||
|
|
||||||
handlebars.registerHelper('encodeURIComponent', encodeURIComponent);
|
handlebars.registerHelper('encodeURIComponent', encodeURIComponent);
|
||||||
|
|
||||||
|
@ -189,61 +190,7 @@ async function getPrBody(config) {
|
||||||
releaseNotes = releaseNotes.replace(/`#​(\d+)`/g, '`#$1`');
|
releaseNotes = releaseNotes.replace(/`#​(\d+)`/g, '`#$1`');
|
||||||
prBody += releaseNotes;
|
prBody += releaseNotes;
|
||||||
}
|
}
|
||||||
prBody += `\n\n---\n\n### ${appName} configuration\n\n`;
|
prBody += await getPrConfigDescription(config);
|
||||||
prBody += `:date: **Schedule**: `;
|
|
||||||
if (
|
|
||||||
config.schedule &&
|
|
||||||
config.schedule !== 'at any time' &&
|
|
||||||
config.schedule[0] !== 'at any time'
|
|
||||||
) {
|
|
||||||
prBody += `"${config.schedule}"`;
|
|
||||||
if (config.timezone) {
|
|
||||||
prBody += ` in timezone ${config.timezone}.`;
|
|
||||||
} else {
|
|
||||||
prBody += ` (UTC).`;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
prBody += 'At any time (no schedule defined).';
|
|
||||||
}
|
|
||||||
|
|
||||||
prBody += '\n\n';
|
|
||||||
prBody += ':vertical_traffic_light: **Automerge**: ';
|
|
||||||
if (config.automerge) {
|
|
||||||
const branchStatus = await platform.getBranchStatus(
|
|
||||||
config.branchName,
|
|
||||||
config.requiredStatusChecks
|
|
||||||
);
|
|
||||||
// istanbul ignore if
|
|
||||||
if (branchStatus === 'failed') {
|
|
||||||
prBody += 'Disabled due to failing status checks.';
|
|
||||||
} else {
|
|
||||||
prBody += 'Enabled.';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
prBody +=
|
|
||||||
'Disabled by config. Please merge this manually once you are satisfied.';
|
|
||||||
}
|
|
||||||
prBody += '\n\n';
|
|
||||||
prBody += ':recycle: **Rebasing**: ';
|
|
||||||
if (config.rebaseStalePrs) {
|
|
||||||
prBody += 'Whenever PR is stale';
|
|
||||||
} else {
|
|
||||||
prBody += 'Whenever PR becomes conflicted';
|
|
||||||
}
|
|
||||||
if (config.platform === 'github') {
|
|
||||||
prBody += `, or if you modify the PR title to begin with "\`rebase!\`".\n\n`;
|
|
||||||
} else {
|
|
||||||
prBody += '.\n\n';
|
|
||||||
}
|
|
||||||
if (config.recreateClosed) {
|
|
||||||
prBody += `:ghost: **Immortal**: This PR will be recreated if closed unmerged. Get [config help](${
|
|
||||||
urls.help
|
|
||||||
}) if that's undesired.\n\n`;
|
|
||||||
} else {
|
|
||||||
prBody += `:no_bell: **Ignore**: Close this PR and you won't be reminded about ${
|
|
||||||
config.upgrades.length === 1 ? 'this update' : 'these updates'
|
|
||||||
} again.\n\n`;
|
|
||||||
}
|
|
||||||
prBody += `\n\n---\n\n - [ ] <!-- ${appSlug}-rebase -->If you want to rebase/retry this PR, check this box\n\n`;
|
prBody += `\n\n---\n\n - [ ] <!-- ${appSlug}-rebase -->If you want to rebase/retry this PR, check this box\n\n`;
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (config.global) {
|
if (config.global) {
|
||||||
|
|
Loading…
Reference in a new issue