- change the default placeholder pattern from ${{}} to #{{}} as this will work for both config.json files and the yaml (${{}} is reserved for github actions syntax)
This commit is contained in:
@@ -70,8 +70,8 @@ export const DefaultConfiguration: Configuration = {
|
||||
order: 'ASC', // the sorting order
|
||||
on_property: 'mergedAt' // the property to sort on. (mergedAt falls back to createdAt)
|
||||
},
|
||||
template: '${{CHANGELOG}}', // the global template to host the changelog
|
||||
pr_template: '- ${{TITLE}}\n - PR: #${{NUMBER}}', // the per PR template to pick
|
||||
template: '#{{CHANGELOG}}', // the global template to host the changelog
|
||||
pr_template: '- #{{TITLE}}\n - PR: ##{{NUMBER}}', // the per PR template to pick
|
||||
empty_template: '- no changes', // the template to use if no pull requests are found
|
||||
categories: [
|
||||
{
|
||||
|
||||
+6
-6
@@ -456,7 +456,7 @@ function handlePlaceholder(
|
||||
placeholderPrMap: Map<string, string[]> | undefined /* map to keep replaced placeholder values with their key */,
|
||||
configuration: Configuration
|
||||
): string {
|
||||
let transformed = template.replaceAll(`\${{${key}}}`, configuration.trim_values ? value.trim() : value)
|
||||
let transformed = template.replaceAll(`#{{${key}}}`, configuration.trim_values ? value.trim() : value)
|
||||
// replace custom placeholders
|
||||
const phs = placeholders.get(key)
|
||||
if (phs) {
|
||||
@@ -470,7 +470,7 @@ function handlePlaceholder(
|
||||
createOrSet(placeholderPrMap, placeholder.name, extractedValue)
|
||||
}
|
||||
transformed = transformed.replaceAll(
|
||||
`\${{${placeholder.name}}}`,
|
||||
`#{{${placeholder.name}}}`,
|
||||
configuration.trim_values ? extractedValue.trim() : extractedValue
|
||||
)
|
||||
|
||||
@@ -542,9 +542,9 @@ function replacePrPlaceholders(
|
||||
let transformed = template
|
||||
for (const [key, values] of placeholderPrMap) {
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
transformed = transformed.replaceAll(`\${{${key}[${i}]}}`, configuration.trim_values ? values[i].trim() : values[i])
|
||||
transformed = transformed.replaceAll(`#{{${key}[${i}]}}`, configuration.trim_values ? values[i].trim() : values[i])
|
||||
}
|
||||
transformed = transformed.replaceAll(`\${{${key}[*]}}`, values.join(''))
|
||||
transformed = transformed.replaceAll(`#{{${key}[*]}}`, values.join(''))
|
||||
}
|
||||
return transformed
|
||||
}
|
||||
@@ -553,7 +553,7 @@ function cleanupPrPlaceholders(template: string, placeholders: Map<string, Place
|
||||
let transformed = template
|
||||
for (const [, phs] of placeholders) {
|
||||
for (const ph of phs) {
|
||||
transformed = transformed.replaceAll(new RegExp(`\\$\\{\\{${ph.name}(?:\\[.+?\\])?\\}\\}`, 'gu'), '')
|
||||
transformed = transformed.replaceAll(new RegExp(`#\\{\\{${ph.name}(?:\\[.+?\\])?\\}\\}`, 'gu'), '')
|
||||
}
|
||||
}
|
||||
return transformed
|
||||
@@ -562,7 +562,7 @@ function cleanupPrPlaceholders(template: string, placeholders: Map<string, Place
|
||||
function cleanupPlaceholders(template: string): string {
|
||||
let transformed = template
|
||||
for (const phs of ['REVIEWS', 'REFERENCED', 'ASSIGNEES', 'REVIEWERS', 'APPROVERS']) {
|
||||
transformed = transformed.replaceAll(new RegExp(`\\$\\{\\{${phs}\\[.+?\\]\\..*?\\}\\}`, 'gu'), '')
|
||||
transformed = transformed.replaceAll(new RegExp(`#\\{\\{${phs}\\[.+?\\]\\..*?\\}\\}`, 'gu'), '')
|
||||
}
|
||||
return transformed
|
||||
}
|
||||
|
||||
+1
-1
@@ -153,7 +153,7 @@ function readConfiguration(filename: string): Configuration | undefined {
|
||||
export function parseConfiguration(config: string): Configuration | undefined {
|
||||
try {
|
||||
// for compatiblity with the `yml` file we require to use `#{{}}` instead of `${{}}` - replace it here.
|
||||
const configurationJSON: Configuration = JSON.parse(config.replace(/#{{/g, '${{'))
|
||||
const configurationJSON: Configuration = JSON.parse(config.replace(/\${{/g, '#{{'))
|
||||
return configurationJSON
|
||||
} catch (error) {
|
||||
core.info(`⚠️ Configuration provided, but it couldn't be parsed. Fallback to Defaults.`)
|
||||
|
||||
Reference in New Issue
Block a user