- cleanup unmatched custom ph:s from pr template

This commit is contained in:
Malte Hallström
2022-08-16 16:05:39 +02:00
parent 117e48acf3
commit e8ee90b94f
2 changed files with 11 additions and 3 deletions
+10 -2
View File
@@ -597,11 +597,19 @@ it('Extract custom placeholder from PR body and replace in global template', asy
pattern: '.+ b(....).+', pattern: '.+ b(....).+',
target: '\n- $1' target: '\n- $1'
} }
},
{
name: 'C_PLACEHOLER_3',
source: 'BODY',
transformer: {
pattern: '.+(body1).+',
target: '$1'
}
} }
] ]
customConfig.template = customConfig.template =
'${{CHANGELOG}}\n\n${{C_PLACEHOLER_2[2]}}\n\n${{C_PLACEHOLER_2[*]}}${{C_PLACEHOLDER_1[7]}}${{C_PLACEHOLER_2[1493]}}' '${{CHANGELOG}}\n\n${{C_PLACEHOLER_2[2]}}\n\n${{C_PLACEHOLER_2[*]}}${{C_PLACEHOLDER_1[7]}}${{C_PLACEHOLER_2[1493]}}'
customConfig.pr_template = '${{BODY}} ----> ${{C_PLACEHOLDER_1}}' customConfig.pr_template = '${{BODY}} ----> ${{C_PLACEHOLDER_1}}${{C_PLACEHOLER_3}}'
const resultChangelog = buildChangelog(DefaultDiffInfo, mergedPullRequests, { const resultChangelog = buildChangelog(DefaultDiffInfo, mergedPullRequests, {
owner: 'mikepenz', owner: 'mikepenz',
@@ -617,6 +625,6 @@ it('Extract custom placeholder from PR body and replace in global template', asy
}) })
expect(resultChangelog).toStrictEqual( expect(resultChangelog).toStrictEqual(
`## 🚀 Features\n\nno magic body1 for this matter ----> - body1\nno magic body3 for this matter ----> - body3\n\n## 🐛 Fixes\n\nno magic body2 for this matter ----> - body2\nno magic body3 for this matter ----> - body3\n\n## 🧪 Others\n\nno magic body4 for this matter ----> - body4\n\n\n\n\n- ody3\n\n\n- ody1\n- ody2\n- ody3\n- ody4` `## 🚀 Features\n\nno magic body1 for this matter ----> - body1body1\nno magic body3 for this matter ----> - body3\n\n## 🐛 Fixes\n\nno magic body2 for this matter ----> - body2\nno magic body3 for this matter ----> - body3\n\n## 🧪 Others\n\nno magic body4 for this matter ----> - body4\n\n\n\n\n- ody3\n\n\n- ody1\n- ody2\n- ody3\n- ody4`
) )
}) })
+1 -1
View File
@@ -379,7 +379,7 @@ function cleanupPrPlaceHolders(
let transformed = template let transformed = template
for (const [, phs] of placeholders) { for (const [, phs] of placeholders) {
for (const ph of phs) { for (const ph of phs) {
transformed = transformed.replaceAll(new RegExp(`\\$\\{\\{${ph.name}\\[.+?\\]\\}\\}`, 'gu'), '') transformed = transformed.replaceAll(new RegExp(`\\$\\{\\{${ph.name}(?:\\[.+?\\])?\\}\\}`, 'gu'), '')
} }
} }
return transformed return transformed