- introduce new API adding support to extract additional PR labels from the PR message. This can also be used to organise the changelog in commitMode
- adjust RegExp to be executed in unicode mode, allows referencing a emoji via `.` - introduce new testcase for emoji mode with label extractor
This commit is contained in:
@@ -9,6 +9,7 @@ export interface Configuration {
|
||||
empty_template: string
|
||||
categories: Category[]
|
||||
ignore_labels: string[]
|
||||
label_extractor: Transformer[]
|
||||
transformers: Transformer[]
|
||||
tag_resolver: TagResolver
|
||||
}
|
||||
@@ -51,6 +52,7 @@ export const DefaultConfiguration: Configuration = {
|
||||
}
|
||||
], // the categories to support for the ordering
|
||||
ignore_labels: ['ignore'], // list of lables being ignored from the changelog
|
||||
label_extractor: [], // extracts additional labels from the commit message given a regex
|
||||
transformers: [], // transformers to apply on the PR description according to the `pr_template`
|
||||
tag_resolver: {
|
||||
// defines the logic on how to resolve the previous tag, only relevant if `fromTag` is not specified
|
||||
|
||||
+14
-1
@@ -19,6 +19,19 @@ export function buildChangelog(
|
||||
prs = sortPullRequests(prs, sortAsc)
|
||||
core.info(`ℹ️ Sorted all pull requests ascending: ${sort}`)
|
||||
|
||||
// extract additional labels from the commit message
|
||||
const labelExtractors = validateTransfomers(config.label_extractor)
|
||||
for (const extractor of labelExtractors) {
|
||||
if (extractor.pattern != null) {
|
||||
for (const pr of prs) {
|
||||
const label = pr.body.replace(extractor.pattern, extractor.target)
|
||||
if (label !== '') {
|
||||
pr.labels.push(label)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const validatedTransformers = validateTransfomers(config.transformers)
|
||||
const transformedMap = new Map<PullRequestInfo, string>()
|
||||
// convert PRs to their text representation
|
||||
@@ -210,7 +223,7 @@ function validateTransfomers(
|
||||
.map(transformer => {
|
||||
try {
|
||||
return {
|
||||
pattern: new RegExp(transformer.pattern.replace('\\\\', '\\'), 'g'),
|
||||
pattern: new RegExp(transformer.pattern.replace('\\\\', '\\'), 'gu'),
|
||||
target: transformer.target
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user