|
2 | 2 | // modifications to improve readability: |
3 | 3 | // - removed thanks notes. We're thanking contributors in the PRs or acknowledge their work in different ways |
4 | 4 | // - moved issue links to end of first line |
| 5 | +// - omit link to merge commit if PR link is found |
| 6 | +// - linkify issue hints like (see #123) or (fixes #567) |
5 | 7 |
|
6 | 8 | const { config } = require('dotenv'); |
7 | 9 | const { getInfo, getInfoFromPullRequest } = require('@changesets/get-github-info'); |
@@ -66,7 +68,14 @@ const changelogFunctions = { |
66 | 68 | }) |
67 | 69 | .trim(); |
68 | 70 |
|
69 | | - const [firstLine, ...futureLines] = replacedChangelog.split('\n').map((l) => l.trimRight()); |
| 71 | + // add links to issue hints (fix #123) => (fix [#123](https://....)) |
| 72 | + const linkifyIssueHints = (line) => |
| 73 | + line.replace(/(?<=\( ?(?:fix|fixes|see) )(#\d+)(?= ?\))/g, (issueHash) => { |
| 74 | + return `[${issueHash}](https://github.com/${options.repo}/issue/${issueHash.substring(1)})`; |
| 75 | + }); |
| 76 | + const [firstLine, ...futureLines] = replacedChangelog |
| 77 | + .split('\n') |
| 78 | + .map((l) => linkifyIssueHints(l.trimRight())); |
70 | 79 |
|
71 | 80 | const links = await (async () => { |
72 | 81 | if (prFromSummary !== undefined) { |
@@ -97,10 +106,8 @@ const changelogFunctions = { |
97 | 106 | }; |
98 | 107 | })(); |
99 | 108 |
|
100 | | - const suffix = [ |
101 | | - links.pull === null ? '' : ` (${links.pull})`, |
102 | | - links.commit === null ? '' : ` (${links.commit})` |
103 | | - ].join(''); |
| 109 | + // only link PR or merge commit not both |
| 110 | + const suffix = links.pull ? ` (${links.pull})` : links.commit ? ` (${links.commit})` : ''; |
104 | 111 |
|
105 | 112 | return `\n\n- ${firstLine}${suffix}\n${futureLines.map((l) => ` ${l}`).join('\n')}`; |
106 | 113 | } |
|
0 commit comments