refactor: ignore apps thanks mentions

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2023-11-09 17:13:43 +01:00
parent c3753c78b5
commit ca6fe027cc
2 changed files with 26 additions and 8 deletions
+18 -7
View File
@@ -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(', ')}! ` : '';
});
}
+8 -1
View File
@@ -4,7 +4,14 @@
"./backstage-changelog.js",
{
"repo": "backstage/backstage",
"ignoreUserThanks": ["benjdlambert", "freben", "jhaals", "Rugvip"]
"ignoreUserThanks": [
"benjdlambert",
"freben",
"jhaals",
"Rugvip",
"renovate",
"dependabot"
]
}
],
"commit": false,