Skip to content

Commit

Permalink
feat: improved warning markdown (#25103)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Oct 9, 2023
1 parent 5163d09 commit 5371266
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 44 deletions.
4 changes: 3 additions & 1 deletion lib/modules/platform/github/index.ts
Expand Up @@ -1770,7 +1770,9 @@ export function massageMarkdown(input: string): string {
'href="https://togithub.com/'
)
.replace(regEx(/]\(https:\/\/github\.com\//g), '](https://togithub.com/')
.replace(regEx(/]: https:\/\/github\.com\//g), ']: https://togithub.com/');
.replace(regEx(/]: https:\/\/github\.com\//g), ']: https://togithub.com/')
.replace('> ⚠ **Warning**\n> \n', '> [!WARNING]\n')
.replace('> ❗ **Important**\n> \n', '> [!IMPORTANT]\n');
return smartTruncate(massagedInput, GitHubMaxPrBodyLen);
}

Expand Down
Expand Up @@ -6,11 +6,10 @@ exports[`workers/repository/dependency-dashboard ensureDependencyDashboard() che
---
### ⚠ Dependency Lookup Warnings ⚠
- Renovate failed to look up the following dependencies: \`dependency-2\`.
Files affected: \`package.json\`
> [!WARNING]
> Renovate failed to look up the following dependencies: \`dependency-2\`.
>
> Files affected: \`package.json\`
---
Expand Down
40 changes: 20 additions & 20 deletions lib/workers/repository/errors-warnings.spec.ts
Expand Up @@ -85,9 +85,9 @@ describe('workers/repository/errors-warnings', () => {
"
---
###Dependency Lookup Warnings ⚠
Warnings were logged while processing this repo. Please check the Dependency Dashboard for more information.
>**Warning**
>
> Some dependencies could not be looked up. Check the Dependency Dashboard for more information.
"
`);
Expand Down Expand Up @@ -133,9 +133,9 @@ describe('workers/repository/errors-warnings', () => {
"
---
###Dependency Lookup Warnings ⚠
Warnings were logged while processing this repo. Please check the logs for more information.
>**Warning**
>
> Some dependencies could not be looked up. Check the warning logs for more information.
"
`);
Expand Down Expand Up @@ -197,11 +197,11 @@ describe('workers/repository/errors-warnings', () => {
"
---
###Dependency Lookup Warnings ⚠
- Renovate failed to look up the following dependencies: \`dependency-1\`, \`dependency-2\`.
Files affected: \`package.json\`, \`backend/package.json\`, \`Dockerfile\`
>**Warning**
>
> Renovate failed to look up the following dependencies: \`dependency-1\`, \`dependency-2\`.
>
> Files affected: \`package.json\`, \`backend/package.json\`, \`Dockerfile\`
---
Expand Down Expand Up @@ -304,15 +304,15 @@ describe('workers/repository/errors-warnings', () => {
expect(res).toMatchInlineSnapshot(`
"
---
###Dependency Lookup Warnings ⚠
Please correct - or verify that you can safely ignore - these lookup failures before you merge this PR.
- \`Warning 1\`
- \`Warning 2\`
Files affected: \`package.json\`, \`backend/package.json\`, \`Dockerfile\`
>
>**Warning**
>
> Please correct - or verify that you can safely ignore - these dependency lookup failures before you merge this PR.
>
> - \`Warning 1\`
> - \`Warning 2\`
>
> Files affected: \`package.json\`, \`backend/package.json\`, \`Dockerfile\`
"
`);
Expand Down
25 changes: 10 additions & 15 deletions lib/workers/repository/errors-warnings.ts
Expand Up @@ -74,15 +74,13 @@ export function getDepWarningsOnboardingPR(
if (!warnings.length) {
return '';
}
warningText = emojify(
`\n---\n\n### :warning: Dependency Lookup Warnings :warning:\n\n`
);
warningText += `Please correct - or verify that you can safely ignore - these lookup failures before you merge this PR.\n\n`;
warningText = emojify(`\n---\n> \n> :warning: **Warning**\n> \n`);
warningText += `> Please correct - or verify that you can safely ignore - these dependency lookup failures before you merge this PR.\n> \n`;
for (const w of warnings) {
warningText += `- \`${w}\`\n`;
warningText += `> - \`${w}\`\n`;
}
warningText +=
'\nFiles affected: ' +
'> \n> Files affected: ' +
warningFiles.map((f) => '`' + f + '`').join(', ') +
'\n\n';
return warningText;
Expand All @@ -101,14 +99,12 @@ export function getDepWarningsPR(
if (!warnings.length) {
return '';
}
warningText = emojify(
`\n---\n\n### :warning: Dependency Lookup Warnings :warning:\n\n`
);
warningText += 'Warnings were logged while processing this repo. ';
warningText = emojify(`\n---\n\n> :warning: **Warning**\n> \n`);
warningText += '> Some dependencies could not be looked up. ';
if (dependencyDashboard) {
warningText += `Please check the Dependency Dashboard for more information.\n\n`;
warningText += `Check the Dependency Dashboard for more information.\n\n`;
} else {
warningText += `Please check the logs for more information.\n\n`;
warningText += `Check the warning logs for more information.\n\n`;
}
return warningText;
}
Expand All @@ -133,11 +129,10 @@ export function getDepWarningsDashboard(
.join(', ');

let warningText = emojify(
`\n---\n\n### :warning: Dependency Lookup Warnings :warning:\n\n`
`\n---\n\n> :warning: **Warning**\n> \n> Renovate failed to look up the following dependencies: `
);
warningText += `- Renovate failed to look up the following dependencies: `;
warningText += depWarnings;
warningText += '.\n\nFiles affected: ';
warningText += '.\n> \n> Files affected: ';
warningText += warningFiles.map((f) => '`' + f + '`').join(', ');
warningText += '\n\n---\n\n';
return warningText;
Expand Down
7 changes: 4 additions & 3 deletions lib/workers/repository/update/pr/index.ts
Expand Up @@ -280,9 +280,10 @@ export async function ensurePr(
upgrade.prBodyNotes = [
...upgrade.prBodyNotes,
[
'\n',
':warning: Release Notes retrieval for this PR were skipped because no github.com credentials were available.',
'If you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/examples/self-hosting.md#githubcom-token-for-release-notes).',
'> :exclamation: **Important**',
'> ',
'> Release Notes retrieval for this PR were skipped because no github.com credentials were available. ',
'> If you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/examples/self-hosting.md#githubcom-token-for-release-notes).',
'\n',
].join('\n'),
];
Expand Down

0 comments on commit 5371266

Please sign in to comment.