mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
refactor: change group config structure
This changes how group are configured to align with the new lock file configuration. BREAKING CHANGE: old group* template options are no longer supported but can be migrated into group object
This commit is contained in:
parent
6f49927a45
commit
3d9cd11611
13 changed files with 35 additions and 46 deletions
|
@ -187,10 +187,12 @@ Obviously, you can't set repository or package file location with this method.
|
|||
| `lazyGrouping` | Use group names only when multiple dependencies upgraded | boolean | `true` | `RENOVATE_LAZY_GROUPING` | `--lazy-grouping` |
|
||||
| `groupName` | Human understandable name for the dependency group | string | `null` | `RENOVATE_GROUP_NAME` | `--group-name` |
|
||||
| `groupSlug` | Slug to use for group (e.g. in branch name). Will be calculated from groupName if null | string | `null` | `RENOVATE_GROUP_SLUG` | `--group-slug` |
|
||||
| `groupBranchName` | Branch name template for the group | string | `"renovate/{{groupSlug}}"` | `RENOVATE_GROUP_BRANCH_NAME` | |
|
||||
| `groupCommitMessage` | Group commit message | string | `"{{semanticPrefix}}Renovate {{groupName}} packages"` | `RENOVATE_GROUP_COMMIT_MESSAGE` | |
|
||||
| `groupPrTitle` | Pull Request title template for the group | string | `"{{semanticPrefix}}Renovate {{groupName}} packages"` | `RENOVATE_GROUP_PR_TITLE` | |
|
||||
| `groupPrBody` | Pull Request body template for the group | string | `"This {{#if isGitHub}}Pull{{else}}Merge{{/if}} Request renovates the package group \"{{groupName}}\".\n\n{{#each upgrades as |upgrade|}}\n- [{{upgrade.depName}}]({{upgrade.repositoryUrl}}): from `{{upgrade.currentVersion}}` to `{{upgrade.newVersion}}`\n{{/each}}\n\n{{#unless isPin}}\n### Commits\n\n{{#each upgrades as |upgrade|}}\n{{#if upgrade.releases.length}}\n<details>\n<summary>{{upgrade.githubName}}</summary>\n{{#each upgrade.releases as |release|}}\n\n#### {{release.version}}\n{{#each release.commits as |commit|}}\n- [`{{commit.shortSha}}`]({{commit.url}}){{commit.message}}\n{{/each}}\n{{/each}}\n\n</details>\n{{/if}}\n{{/each}}\n{{/unless}}\n<br />\n\nThis {{#if isGitHub}}PR{{else}}MR{{/if}} has been generated by [Renovate Bot](https://keylocation.sg/our-tech/renovate)."` | `RENOVATE_GROUP_PR_BODY` | |
|
||||
| `group` | Config if groupName is enabled | json | `{
|
||||
"branchName": "renovate/{{groupSlug}}",
|
||||
"commitMessage": "{{semanticPrefix}}Renovate {{groupName}} packages",
|
||||
"prTitle": "{{semanticPrefix}}Renovate {{groupName}} packages",
|
||||
"prBody": "This {{#if isGitHub}}Pull{{else}}Merge{{/if}} Request renovates the package group \"{{groupName}}\".\n\n{{#each upgrades as |upgrade|}}\n- [{{upgrade.depName}}]({{upgrade.repositoryUrl}}): from `{{upgrade.currentVersion}}` to `{{upgrade.newVersion}}`\n{{/each}}\n\n{{#unless isPin}}\n### Commits\n\n{{#each upgrades as |upgrade|}}\n{{#if upgrade.releases.length}}\n<details>\n<summary>{{upgrade.githubName}}</summary>\n{{#each upgrade.releases as |release|}}\n\n#### {{release.version}}\n{{#each release.commits as |commit|}}\n- [`{{commit.shortSha}}`]({{commit.url}}){{commit.message}}\n{{/each}}\n{{/each}}\n\n</details>\n{{/if}}\n{{/each}}\n{{/unless}}\n<br />\n\nThis {{#if isGitHub}}PR{{else}}MR{{/if}} has been generated by [Renovate Bot](https://keylocation.sg/our-tech/renovate)."
|
||||
}` | `RENOVATE_GROUP` | |
|
||||
| `labels` | Labels to add to Pull Request | list | `[]` | `RENOVATE_LABELS` | `--labels` |
|
||||
| `assignees` | Assignees for Pull Request | list | `[]` | `RENOVATE_ASSIGNEES` | `--assignees` |
|
||||
| `reviewers` | Requested reviewers for Pull Requests (GitHub only) | list | `[]` | `RENOVATE_REVIEWERS` | `--reviewers` |
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function template(name) {
|
||||
function template(name, subdir = 'default/') {
|
||||
const shortName = `${name.replace(/([A-Z])/g, '-$1').toLowerCase()}.hbs`;
|
||||
const hbsContents = fs.readFileSync(
|
||||
// Long path is so that it works whether code is run from lib or dist
|
||||
path.resolve(__dirname, '../../lib/config/templates/', shortName),
|
||||
path.resolve(__dirname, '../../lib/config/templates/', subdir, shortName),
|
||||
'utf8'
|
||||
);
|
||||
// Strip off any trailing line break
|
||||
|
@ -215,7 +215,7 @@ const options = [
|
|||
default: 'pr',
|
||||
onboarding: false,
|
||||
},
|
||||
// String templates
|
||||
// Default templates
|
||||
{
|
||||
name: 'branchName',
|
||||
description: 'Branch name template',
|
||||
|
@ -297,36 +297,19 @@ const options = [
|
|||
onboarding: false,
|
||||
},
|
||||
{
|
||||
name: 'groupBranchName',
|
||||
description: 'Branch name template for the group',
|
||||
type: 'string',
|
||||
default: template('groupBranchName'),
|
||||
cli: false,
|
||||
onboarding: false,
|
||||
},
|
||||
{
|
||||
name: 'groupCommitMessage',
|
||||
description: 'Group commit message',
|
||||
type: 'string',
|
||||
default: template('groupCommitMessage'),
|
||||
cli: false,
|
||||
onboarding: false,
|
||||
},
|
||||
{
|
||||
name: 'groupPrTitle',
|
||||
description: 'Pull Request title template for the group',
|
||||
type: 'string',
|
||||
default: template('groupPrTitle'),
|
||||
cli: false,
|
||||
onboarding: false,
|
||||
},
|
||||
{
|
||||
name: 'groupPrBody',
|
||||
description: 'Pull Request body template for the group',
|
||||
type: 'string',
|
||||
default: template('groupPrBody'),
|
||||
name: 'group',
|
||||
description: 'Config if groupName is enabled',
|
||||
type: 'json',
|
||||
default: {
|
||||
branchName: template('branchName', 'group'),
|
||||
commitMessage: template('commitMessage', 'group'),
|
||||
prTitle: template('prTitle', 'group'),
|
||||
prBody: template('prBody', 'group'),
|
||||
},
|
||||
cli: false,
|
||||
env: false,
|
||||
onboarding: false,
|
||||
mergeable: true,
|
||||
},
|
||||
// Pull Request options
|
||||
{
|
||||
|
|
|
@ -36,18 +36,18 @@ async function groupUpgradesByBranch(upgrades, logger) {
|
|||
// Check whether to use a group name
|
||||
let branchName;
|
||||
if (upgrade.groupName) {
|
||||
upgrade.groupSlug =
|
||||
upgrade.groupSlug ||
|
||||
upgrade.groupName.toLowerCase().replace(/[^a-z0-9+]+/g, '-');
|
||||
branchName = handlebars.compile(upgrade.groupBranchName)(upgrade);
|
||||
logger.debug(
|
||||
{ branchName },
|
||||
`Dependency ${upgrade.depName} is part of group '${upgrade.groupName}'`
|
||||
);
|
||||
upgrade.groupSlug =
|
||||
upgrade.groupSlug ||
|
||||
upgrade.groupName.toLowerCase().replace(/[^a-z0-9+]+/g, '-');
|
||||
branchName = handlebars.compile(upgrade.group.branchName)(upgrade);
|
||||
if (branchUpgrades[branchName]) {
|
||||
upgrade.commitMessage = upgrade.groupCommitMessage;
|
||||
upgrade.prTitle = upgrade.groupPrTitle;
|
||||
upgrade.prBody = upgrade.groupPrBody;
|
||||
upgrade.commitMessage = upgrade.group.commitMessage;
|
||||
upgrade.prTitle = upgrade.group.prTitle;
|
||||
upgrade.prBody = upgrade.group.prBody;
|
||||
}
|
||||
} else {
|
||||
branchName = handlebars.compile(upgrade.branchName)(upgrade);
|
||||
|
|
|
@ -56,7 +56,9 @@ Object {
|
|||
Object {
|
||||
"branchName": "bar-{{version}}",
|
||||
"commitMessage": undefined,
|
||||
"groupBranchName": "renovate/my-group",
|
||||
"group": Object {
|
||||
"branchName": "renovate/my-group",
|
||||
},
|
||||
"groupName": "My Group",
|
||||
"groupSlug": "my-group",
|
||||
"prBody": undefined,
|
||||
|
@ -65,7 +67,9 @@ Object {
|
|||
},
|
||||
Object {
|
||||
"branchName": "foo",
|
||||
"groupBranchName": "renovate/{{groupSlug}}",
|
||||
"group": Object {
|
||||
"branchName": "renovate/{{groupSlug}}",
|
||||
},
|
||||
"groupName": "My Group",
|
||||
"groupSlug": "my-group",
|
||||
"version": "1.1.0",
|
||||
|
|
|
@ -104,7 +104,7 @@ describe('workers/repository/upgrades', () => {
|
|||
branchName: 'foo',
|
||||
version: '1.1.0',
|
||||
groupName: 'My Group',
|
||||
groupBranchName: 'renovate/{{groupSlug}}',
|
||||
group: { branchName: 'renovate/{{groupSlug}}' },
|
||||
},
|
||||
{
|
||||
branchName: 'foo',
|
||||
|
@ -114,7 +114,7 @@ describe('workers/repository/upgrades', () => {
|
|||
branchName: 'bar-{{version}}',
|
||||
version: '1.1.0',
|
||||
groupName: 'My Group',
|
||||
groupBranchName: 'renovate/my-group',
|
||||
group: { branchName: 'renovate/my-group' },
|
||||
},
|
||||
];
|
||||
const res = await upgrades.groupUpgradesByBranch(input, logger);
|
||||
|
|
Loading…
Reference in a new issue