feat: keep labels in a set and make them lowercase

This commit is contained in:
invakid404
2021-06-23 10:31:36 +03:00
parent dead522cc2
commit dead9527b4
4 changed files with 47 additions and 35 deletions
+4 -4
View File
@@ -39,7 +39,7 @@ export function buildChangelog(
label = pr.body.replace(extractor.pattern, extractor.target)
}
if (label !== '') {
pr.labels.push(label)
pr.labels.add(label.toLowerCase())
}
}
}
@@ -189,8 +189,8 @@ export function fillAdditionalPlaceholders(
return transformed
}
function haveCommonElements(arr1: string[], arr2: string[]): Boolean {
return arr1.some(item => arr2.includes(item))
function haveCommonElements(arr1: string[], arr2: Set<string>): Boolean {
return arr1.some(item => arr2.has(item))
}
function fillTemplate(pr: PullRequestInfo, template: string): string {
@@ -205,7 +205,7 @@ function fillTemplate(pr: PullRequestInfo, template: string): string {
transformed = transformed.replace(/\${{AUTHOR}}/g, pr.author)
transformed = transformed.replace(
/\${{LABELS}}/g,
pr.labels?.join(', ') || ''
[...pr.labels]?.join(', ') || ''
)
transformed = transformed.replace(/\${{MILESTONE}}/g, pr.milestone || '')
transformed = transformed.replace(/\${{BODY}}/g, pr.body)