- add logic which cleans up custom placeholders with the [] syntax which were not matched
This commit is contained in:
@@ -255,6 +255,7 @@ export function buildChangelog(diffInfo: DiffInfo, prs: PullRequestInfo[], optio
|
||||
let transformedChangelog = config.template || DefaultConfiguration.template
|
||||
transformedChangelog = replacePlaceholders(transformedChangelog, placeholderMap, placeholders, placeholderPrMap)
|
||||
transformedChangelog = replacePrPlaceholders(transformedChangelog, placeholderPrMap)
|
||||
transformedChangelog = cleanupPrPlaceHolders(transformedChangelog, placeholders)
|
||||
core.info(`ℹ️ Filled template`)
|
||||
return transformedChangelog
|
||||
}
|
||||
@@ -361,6 +362,19 @@ function replacePrPlaceholders(
|
||||
return transformed
|
||||
}
|
||||
|
||||
function cleanupPrPlaceHolders(
|
||||
template: string,
|
||||
placeholders: Map<string, Placeholder[]> /* placeholders to apply */
|
||||
): string {
|
||||
let transformed = template
|
||||
for (const [, phs] of placeholders) {
|
||||
for (const ph of phs) {
|
||||
transformed = transformed.replaceAll(new RegExp(`\\$\\{\\{${ph.name}\\[.+?\\]\\}\\}`, 'gu'), '')
|
||||
}
|
||||
}
|
||||
return transformed
|
||||
}
|
||||
|
||||
function transform(filled: string, transformers: RegexTransformer[]): string {
|
||||
if (transformers.length === 0) {
|
||||
return filled
|
||||
|
||||
Reference in New Issue
Block a user