fix: Improve PR body fixes for scoped packages (#569)

Escape all scoped package mentions
Escape in group PR bodies too
Remove empty repositoryUrl links
This commit is contained in:
Rhys Arkins 2017-08-01 08:49:41 +02:00 committed by singapore
parent 6cd398f0c5
commit f1d7330f2b
5 changed files with 10 additions and 7 deletions

View file

@ -1,4 +1,4 @@
This {{#if isGitHub}}Pull{{else}}Merge{{/if}} Request {{#if isRollback}}rolls back{{else}}updates{{/if}} dependency {{#if repositoryUrl}}[{{depName}}]({{repositoryUrl}}){{else}}`depName`{{/if}} from version `{{currentVersion}}` to `{{newVersion}}`{{#if isRollback}}. This is necessary and important because version `{{currentVersion}}` cannot be found in the npm registry - probably because of it being unpublished.{{/if}} This {{#if isGitHub}}Pull{{else}}Merge{{/if}} Request {{#if isRollback}}rolls back{{else}}updates{{/if}} dependency {{#if repositoryUrl}}[{{depName}}]({{repositoryUrl}}){{else}}`{{depName}}`{{/if}} from version `{{currentVersion}}` to `{{newVersion}}`{{#if isRollback}}. This is necessary and important because version `{{currentVersion}}` cannot be found in the npm registry - probably because of it being unpublished.{{/if}}
{{#if releases.length}} {{#if releases.length}}
{{#if schedule}} {{#if schedule}}

View file

@ -5,7 +5,7 @@ This {{#if isGitHub}}Pull{{else}}Merge{{/if}} Request renovates the package grou
{{/if}} {{/if}}
{{#each upgrades as |upgrade|}} {{#each upgrades as |upgrade|}}
- [{{upgrade.depName}}]({{upgrade.repositoryUrl}}): from `{{upgrade.currentVersion}}` to `{{upgrade.newVersion}}` - {{#if repositoryUrl}}[{{upgrade.depName}}]({{upgrade.repositoryUrl}}){{else}}`{{depName}}`{{/if}}: from `{{upgrade.currentVersion}}` to `{{upgrade.newVersion}}`
{{/each}} {{/each}}
{{#unless isPin}} {{#unless isPin}}

View file

@ -50,7 +50,10 @@ async function renovatePackage(config) {
// Flatten the result on top of config, add repositoryUrl // Flatten the result on top of config, add repositoryUrl
return results.map(result => { return results.map(result => {
const upg = configParser.mergeChildConfig(config, result); const upg = configParser.mergeChildConfig(config, result);
upg.repositoryUrl = npmDep ? npmDep.repositoryUrl : ''; upg.repositoryUrl =
npmDep && npmDep.repositoryUrl && npmDep.repositoryUrl.length
? npmDep.repositoryUrl
: null;
return configParser.filterConfig(upg, 'branch'); return configParser.filterConfig(upg, 'branch');
}); });
} }

View file

@ -115,7 +115,7 @@ async function ensurePr(inputConfig, logger, errors, warnings) {
const prTitle = handlebars.compile(config.prTitle)(config); const prTitle = handlebars.compile(config.prTitle)(config);
let prBodyMarkdown = handlebars.compile(config.prBody)(config); let prBodyMarkdown = handlebars.compile(config.prBody)(config);
const atUserRe = /@([a-z]+\/[a-z]+)/; const atUserRe = /[^`]@([a-z]+\/[a-z]+)/g;
prBodyMarkdown = prBodyMarkdown.replace(atUserRe, '@​$1'); prBodyMarkdown = prBodyMarkdown.replace(atUserRe, '@​$1');
const prBody = converter.makeHtml(prBodyMarkdown); const prBody = converter.makeHtml(prBodyMarkdown);

View file

@ -49,7 +49,7 @@ Array [
{{/if}} {{/if}}
{{#each upgrades as |upgrade|}} {{#each upgrades as |upgrade|}}
- [{{upgrade.depName}}]({{upgrade.repositoryUrl}}): from \`{{upgrade.currentVersion}}\` to \`{{upgrade.newVersion}}\` - {{#if repositoryUrl}}[{{upgrade.depName}}]({{upgrade.repositoryUrl}}){{else}}\`{{depName}}\`{{/if}}: from \`{{upgrade.currentVersion}}\` to \`{{upgrade.newVersion}}\`
{{/each}} {{/each}}
{{#unless isPin}} {{#unless isPin}}
@ -110,7 +110,7 @@ This {{#if isGitHub}}PR{{else}}MR{{/if}} has been generated by [Renovate Bot](ht
"labels": Array [], "labels": Array [],
"lazyGrouping": true, "lazyGrouping": true,
"message": "Failed to look up dependency", "message": "Failed to look up dependency",
"prBody": "This {{#if isGitHub}}Pull{{else}}Merge{{/if}} Request {{#if isRollback}}rolls back{{else}}updates{{/if}} dependency {{#if repositoryUrl}}[{{depName}}]({{repositoryUrl}}){{else}}\`depName\`{{/if}} from version \`{{currentVersion}}\` to \`{{newVersion}}\`{{#if isRollback}}. This is necessary and important because version \`{{currentVersion}}\` cannot be found in the npm registry - probably because of it being unpublished.{{/if}} "prBody": "This {{#if isGitHub}}Pull{{else}}Merge{{/if}} Request {{#if isRollback}}rolls back{{else}}updates{{/if}} dependency {{#if repositoryUrl}}[{{depName}}]({{repositoryUrl}}){{else}}\`{{depName}}\`{{/if}} from version \`{{currentVersion}}\` to \`{{newVersion}}\`{{#if isRollback}}. This is necessary and important because version \`{{currentVersion}}\` cannot be found in the npm registry - probably because of it being unpublished.{{/if}}
{{#if releases.length}} {{#if releases.length}}
{{#if schedule}} {{#if schedule}}
@ -166,7 +166,7 @@ This {{#if isGitHub}}PR{{else}}MR{{/if}} has been generated by [Renovate Bot](ht
"rebaseStalePrs": false, "rebaseStalePrs": false,
"recreateClosed": false, "recreateClosed": false,
"repoIsOnboarded": true, "repoIsOnboarded": true,
"repositoryUrl": "", "repositoryUrl": null,
"requiredStatusChecks": Array [], "requiredStatusChecks": Array [],
"reviewers": Array [], "reviewers": Array [],
"schedule": "some schedule", "schedule": "some schedule",