Skip to content

Commit

Permalink
fix(config): improve config migration PR body and title (#16355)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins authored Jul 1, 2022
1 parent a07fb52 commit 2c78703
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 142 deletions.
3 changes: 3 additions & 0 deletions lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ const options: RenovateOptions[] = [
stage: 'repository',
type: 'boolean',
default: false,
experimental: true,
experimentalDescription:
'Config migration PRs are still being improved, in particular to reduce the amount of reordering and whitespace changes.',
},
{
name: 'productLinks',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`workers/repository/config-migration/pr/index ensureConfigMigrationPr() creates PR for JSON5 config file 1`] = `
"Config migration needed, merge this PR to update your Renovate configuration file.
"The Renovate config in this repository needs migrating. Typically this is because one or more configuration options you are using have been renamed.
You don't need to merge this PR right away, because Renovate will continue to migrate these fields internally each time it runs. But later some of these fields may be fully deprecated and the migrations removed. So it's a good idea to merge this migration PR soon.
#### [PLEASE NOTE](https://docs.renovatebot.com/configuration-options#configmigration): JSON5 config file migrated! All comments & trailing commas were removed.
---
#### Migration completed successfully, No errors or warnings found.
---
❓ Got questions? Does something look wrong to you? Please don't hesitate to [request help here](https://github.com/renovatebot/renovate/discussions).
❓ Got questions? Check out Renovate's [Docs](https://docs.renovatebot.com/), particularly the Getting Started section.
If you need any further assistance then you can also [request help here](https://github.com/renovatebot/renovate/discussions).
---
Expand All @@ -23,18 +21,16 @@ This PR has been generated by [Renovate Bot](https://github.com/renovatebot/reno
exports[`workers/repository/config-migration/pr/index ensureConfigMigrationPr() creates PR with empty footer and header 1`] = `
"
Config migration needed, merge this PR to update your Renovate configuration file.
The Renovate config in this repository needs migrating. Typically this is because one or more configuration options you are using have been renamed.
You don't need to merge this PR right away, because Renovate will continue to migrate these fields internally each time it runs. But later some of these fields may be fully deprecated and the migrations removed. So it's a good idea to merge this migration PR soon.
---
#### Migration completed successfully, No errors or warnings found.
---
❓ Got questions? Does something look wrong to you? Please don't hesitate to [request help here](https://github.com/renovatebot/renovate/discussions).
❓ Got questions? Check out Renovate's [Docs](https://docs.renovatebot.com/), particularly the Getting Started section.
If you need any further assistance then you can also [request help here](https://github.com/renovatebot/renovate/discussions).
---
Expand All @@ -45,18 +41,16 @@ If you need any further assistance then you can also [request help here](https:/
exports[`workers/repository/config-migration/pr/index ensureConfigMigrationPr() creates PR with footer and header using templating 1`] = `
"This is a header for platform:github
Config migration needed, merge this PR to update your Renovate configuration file.
The Renovate config in this repository needs migrating. Typically this is because one or more configuration options you are using have been renamed.
You don't need to merge this PR right away, because Renovate will continue to migrate these fields internally each time it runs. But later some of these fields may be fully deprecated and the migrations removed. So it's a good idea to merge this migration PR soon.
---
#### Migration completed successfully, No errors or warnings found.
---
❓ Got questions? Does something look wrong to you? Please don't hesitate to [request help here](https://github.com/renovatebot/renovate/discussions).
❓ Got questions? Check out Renovate's [Docs](https://docs.renovatebot.com/), particularly the Getting Started section.
If you need any further assistance then you can also [request help here](https://github.com/renovatebot/renovate/discussions).
---
Expand All @@ -69,18 +63,16 @@ exports[`workers/repository/config-migration/pr/index ensureConfigMigrationPr()
This should not be the first line of the PR
Config migration needed, merge this PR to update your Renovate configuration file.
The Renovate config in this repository needs migrating. Typically this is because one or more configuration options you are using have been renamed.
You don't need to merge this PR right away, because Renovate will continue to migrate these fields internally each time it runs. But later some of these fields may be fully deprecated and the migrations removed. So it's a good idea to merge this migration PR soon.
---
#### Migration completed successfully, No errors or warnings found.
---
❓ Got questions? Does something look wrong to you? Please don't hesitate to [request help here](https://github.com/renovatebot/renovate/discussions).
❓ Got questions? Check out Renovate's [Docs](https://docs.renovatebot.com/), particularly the Getting Started section.
If you need any further assistance then you can also [request help here](https://github.com/renovatebot/renovate/discussions).
---
Expand Down
57 changes: 0 additions & 57 deletions lib/workers/repository/config-migration/pr/errors-warnings.spec.ts

This file was deleted.

28 changes: 0 additions & 28 deletions lib/workers/repository/config-migration/pr/errors-warnings.ts

This file was deleted.

2 changes: 0 additions & 2 deletions lib/workers/repository/config-migration/pr/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ describe('workers/repository/config-migration/pr/index', () => {
...getConfig(),
configMigration: true,
defaultBranch: 'main',
errors: [],
warnings: [],
description: [],
};
});
Expand Down
40 changes: 9 additions & 31 deletions lib/workers/repository/config-migration/pr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { prepareLabels } from '../../update/pr/labels';
import { addParticipants } from '../../update/pr/participants';
import type { MigratedData } from '../branch/migrated-data';
import { getMigrationBranchName } from '../common';
import { getErrors, getWarnings } from './errors-warnings';

export async function ensureConfigMigrationPr(
config: RenovateConfig,
Expand All @@ -26,7 +25,7 @@ export async function ensureConfigMigrationPr(
'configuration-options/#configmigration'
);
const branchName = getMigrationBranchName(config);
const prTitle = config.onboardingPrTitle ?? 'Config Migration';
const prTitle = 'Migrate Renovate config';
const existingPr = await platform.getBranchPr(branchName);
const closedPr = await platform.findPr({
branchName,
Expand All @@ -35,8 +34,10 @@ export async function ensureConfigMigrationPr(
});
const filename = migratedConfigData.filename;
logger.debug('Filling in config migration PR template');
let prTemplate = `Config migration needed, merge this PR to update your Renovate configuration file.\n\n`;
prTemplate += emojify(
let prBody = `The Renovate config in this repository needs migrating. Typically this is because one or more configuration options you are using have been renamed.
You don't need to merge this PR right away, because Renovate will continue to migrate these fields internally each time it runs. But later some of these fields may be fully deprecated and the migrations removed. So it's a good idea to merge this migration PR soon. \n\n`;
prBody += emojify(
`
${
Expand All @@ -45,33 +46,12 @@ ${
`JSON5 config file migrated! All comments & trailing commas were removed.`
: ''
}
---
{{#if hasWarningsErrors}}
{{{warnings}}}
{{{errors}}}
{{else}}
#### Migration completed successfully, No errors or warnings found.
{{/if}}
---
:question: Got questions? Check out Renovate's [Docs](${
config.productLinks?.documentation
}), particularly the Getting Started section.
If you need any further assistance then you can also [request help here](${
:question: Got questions? Does something look wrong to you? Please don't hesitate to [request help here](${
config.productLinks?.help
}).
`
}).\n\n`
);
const warnings = getWarnings(config);
const errors = getErrors(config);
const hasWarningsErrors = warnings || errors;
let prBody = prTemplate;
prBody = template.compile(prBody, {
warnings,
errors,
hasWarningsErrors,
});

if (is.string(config.prHeader)) {
prBody = `${template.compile(config.prHeader, config)}\n\n${prBody}`;
}
Expand Down Expand Up @@ -103,9 +83,7 @@ If you need any further assistance then you can also [request help here](${
}
return;
}
if (
[config.onboardingPrTitle, 'Config Migration'].includes(closedPr?.title)
) {
if (closedPr) {
logger.debug('Found closed migration PR, exiting...');
return;
}
Expand Down

0 comments on commit 2c78703

Please sign in to comment.