fix: Escape scoped package names in PR bodies (#568)

GitHub attempts to autolink any @user mention and this causes problems when we use scoped npm modules like `@types/gulp`. This escapes such package names with a zero width space to fool GitHub’s parser.

Fixes #518
This commit is contained in:
Rhys Arkins 2017-08-01 07:22:43 +02:00 committed by GitHub
parent 8374ef6caa
commit 6cd398f0c5
3 changed files with 5 additions and 3 deletions

View file

@ -1,4 +1,4 @@
This {{#if isGitHub}}Pull{{else}}Merge{{/if}} Request {{#if isRollback}}rolls back{{else}}updates{{/if}} dependency [{{depName}}]({{repositoryUrl}}) 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 schedule}}

View file

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

View file

@ -110,7 +110,7 @@ This {{#if isGitHub}}PR{{else}}MR{{/if}} has been generated by [Renovate Bot](ht
"labels": Array [],
"lazyGrouping": true,
"message": "Failed to look up dependency",
"prBody": "This {{#if isGitHub}}Pull{{else}}Merge{{/if}} Request {{#if isRollback}}rolls back{{else}}updates{{/if}} dependency [{{depName}}]({{repositoryUrl}}) 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 schedule}}