From ca6fe027cc1fc4fc8df5c7f17b4bc5e9801705af Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Thu, 9 Nov 2023 17:13:43 +0100 Subject: [PATCH] refactor: ignore apps thanks mentions Signed-off-by: Camila Belo --- .changeset/backstage-changelog.js | 25 ++++++++++++++++++------- .changeset/config.json | 9 ++++++++- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/.changeset/backstage-changelog.js b/.changeset/backstage-changelog.js index 61734f9f67..45ed53afe4 100644 --- a/.changeset/backstage-changelog.js +++ b/.changeset/backstage-changelog.js @@ -33,17 +33,28 @@ async function getDependencyReleaseLine(changesets, dependenciesUpdated) { } async function getReleaseLine(changeset, type, options) { - const { ignoreUserThanks: users = [] } = options ?? {}; - const ignoredLinks = new Set( - users.map(user => `[@${user}](https://github.com/${user})`), - ); + const { ignoreUserThanks = [], ...rest } = options ?? {}; const releaseLine = await defaultChangelogFunctions.getReleaseLine( changeset, type, - options, + rest, ); - return releaseLine.replace(/Thanks\s(.*)!\s/g, (_, group) => { - const links = group.split(', ').filter(link => !ignoredLinks.has(link)); + + const ignoredUsers = new Set(ignoreUserThanks); + return releaseLine.replace(/Thanks\s(.*)!\s/g, (_, text) => { + // extracts user name and profile url from the markdown link + const regex = /\[@(\w+)\]\((https:\/\/github\.com\/[^\)]+)\)/g; + + let matches; + const links = []; + + while ((matches = regex.exec(text)) !== null) { + const [, user, url] = matches; + if (!ignoredUsers.has(user)) { + links.push(`[@${user}](${url})`); + } + } + return links.length ? `Thanks ${links.join(', ')}! ` : ''; }); } diff --git a/.changeset/config.json b/.changeset/config.json index fe78edc9cf..94e435bd93 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -4,7 +4,14 @@ "./backstage-changelog.js", { "repo": "backstage/backstage", - "ignoreUserThanks": ["benjdlambert", "freben", "jhaals", "Rugvip"] + "ignoreUserThanks": [ + "benjdlambert", + "freben", + "jhaals", + "Rugvip", + "renovate", + "dependabot" + ] } ], "commit": false,