Fix Transformation of Issue/PR Tags in Changelog (#966)

[SKIP]
This commit is contained in:
Integer Limit 2024-08-27 16:50:17 +10:00 committed by GitHub
parent 6dbfc54184
commit ccfcd1e583
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -374,6 +374,7 @@ async function transformAllIssueURLs(changelog: string[]) {
*/ */
async function transformTags(message: string): Promise<string> { async function transformTags(message: string): Promise<string> {
const promises: Promise<string>[] = []; const promises: Promise<string>[] = [];
const transformed: Set<number> = new Set<number>();
if (message.search(/#\d+/) !== -1) { if (message.search(/#\d+/) !== -1) {
const matched = message.match(/#\d+/g) ?? []; const matched = message.match(/#\d+/g) ?? [];
for (const match of matched) { for (const match of matched) {
@ -382,10 +383,14 @@ async function transformTags(message: string): Promise<string> {
if (!digitsMatch) continue; if (!digitsMatch) continue;
const digits = Number.parseInt(digitsMatch[0]); const digits = Number.parseInt(digitsMatch[0]);
if (transformed.has(digits)) continue;
transformed.add(digits);
// Get PR/Issue Info (PRs are listed in the Issue API Endpoint) // Get PR/Issue Info (PRs are listed in the Issue API Endpoint)
promises.push( promises.push(
getIssueURL(digits).then((url) => getIssueURL(digits).then(
message.replace(match, `[#${digits}](${url})`), (url) =>
(message = message.replaceAll(match, `[#${digits}](${url})`)),
), ),
); );
} }