@@ -318,6 +318,7 @@ Table of descriptions for the `configuration.json` options to configure the resu
|
|||||||
| label_extractor.on_property | The property to retrieve the text from. This is optional. Defaults to: `body`. Alternative values: `title`, `author`, `milestone`. |
|
| label_extractor.on_property | The property to retrieve the text from. This is optional. Defaults to: `body`. Alternative values: `title`, `author`, `milestone`. |
|
||||||
| label_extractor.method | The extraction method used. Defaults to: `replace`. Alternative value: `match`. The method specified references the JavaScript String method. |
|
| label_extractor.method | The extraction method used. Defaults to: `replace`. Alternative value: `match`. The method specified references the JavaScript String method. |
|
||||||
| label_extractor.flags | Defines the regex flags specified for the pattern. Default: `gu` |
|
| label_extractor.flags | Defines the regex flags specified for the pattern. Default: `gu` |
|
||||||
|
| label_extractor.on_empty | Defines the placeholder to be filled in, if the regex does not lead to a result. |
|
||||||
| duplicate_filter | Defines the `Extractor` to use for retrieving the identifier for a PR. In case of duplicates will keep the last matching pull request (depends on `sort`). See `label_extractor` for details on `Extractor` properties. |
|
| duplicate_filter | Defines the `Extractor` to use for retrieving the identifier for a PR. In case of duplicates will keep the last matching pull request (depends on `sort`). See `label_extractor` for details on `Extractor` properties. |
|
||||||
| transformers | An array of `transform` specifications, offering a flexible API to modify the text per pull request. This is applied on the change text created with `pr_template`. `transformers` are executed per change, in the order specified |
|
| transformers | An array of `transform` specifications, offering a flexible API to modify the text per pull request. This is applied on the change text created with `pr_template`. `transformers` are executed per change, in the order specified |
|
||||||
| transformer.pattern | A `regex` pattern, extracting values of the change message. |
|
| transformer.pattern | A `regex` pattern, extracting values of the change message. |
|
||||||
@@ -329,6 +330,7 @@ Table of descriptions for the `configuration.json` options to configure the resu
|
|||||||
| tag_resolver | Section to provide configuration for the tag resolving logic. Used if no `fromTag` is provided |
|
| tag_resolver | Section to provide configuration for the tag resolving logic. Used if no `fromTag` is provided |
|
||||||
| tag_resolver.method | Defines the method to use. Current options are: `semver`, `sort`. Default: `semver` |
|
| tag_resolver.method | Defines the method to use. Current options are: `semver`, `sort`. Default: `semver` |
|
||||||
| tag_resolver.filter | Defines a regex which is used to filter out tags not matching. |
|
| tag_resolver.filter | Defines a regex which is used to filter out tags not matching. |
|
||||||
|
| tag_resolver.transformer | Defines a regex transformer used to optionally transform the tag after the filter was applied. Allows to adjust the format to e.g. semver. |
|
||||||
| base_branches | The target branches for the merged PR, ingnores PRs with different target branch. Values can be a `regex`. Default: allow all base branches |
|
| base_branches | The target branches for the merged PR, ingnores PRs with different target branch. Values can be a `regex`. Default: allow all base branches |
|
||||||
|
|
||||||
## Contribute 🧬
|
## Contribute 🧬
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ configuration.categories = [
|
|||||||
{
|
{
|
||||||
title: '## 🧪 Tests',
|
title: '## 🧪 Tests',
|
||||||
labels: ['[Test]']
|
labels: ['[Test]']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '## 🧪 Others',
|
||||||
|
labels: ['[Other]']
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -192,6 +196,31 @@ it('Extract label from title, match multiple', async () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Extract label from title, match multiple, custon non matching label', async () => {
|
||||||
|
configuration.label_extractor = [
|
||||||
|
{
|
||||||
|
pattern: '\\[Feature\\]|\\[Issue\\]',
|
||||||
|
on_property: 'title',
|
||||||
|
method: 'match',
|
||||||
|
on_empty: '[Other]'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
const resultChangelog = buildChangelog(mergedPullRequests, {
|
||||||
|
owner: 'mikepenz',
|
||||||
|
repo: 'test-repo',
|
||||||
|
fromTag: '1.0.0',
|
||||||
|
toTag: '2.0.0',
|
||||||
|
failOnError: false,
|
||||||
|
commitMode: false,
|
||||||
|
configuration
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(resultChangelog).toStrictEqual(
|
||||||
|
`## 🚀 Features\n\n- [Feature][AB-1234] - this is a PR 1 title message\n - PR: #1\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n## 🐛 Fixes\n\n- [Issue][AB-4321] - this is a PR 2 title message\n - PR: #2\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n## 🧪 Others\n\n- [AB-404] - not found label\n - PR: #4\n\n`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
// test set of PRs with lables predefined
|
// test set of PRs with lables predefined
|
||||||
const pullRequestsWithLabels: PullRequestInfo[] = []
|
const pullRequestsWithLabels: PullRequestInfo[] = []
|
||||||
pullRequestsWithLabels.push(
|
pullRequestsWithLabels.push(
|
||||||
|
|||||||
+61
-6
@@ -174,7 +174,8 @@ exports.DefaultConfiguration = {
|
|||||||
tag_resolver: {
|
tag_resolver: {
|
||||||
// defines the logic on how to resolve the previous tag, only relevant if `fromTag` is not specified
|
// defines the logic on how to resolve the previous tag, only relevant if `fromTag` is not specified
|
||||||
method: 'semver',
|
method: 'semver',
|
||||||
filter: undefined // filter out all tags not matching the regex
|
filter: undefined,
|
||||||
|
transformer: undefined // transforms the tag name using the regex, run after the filter
|
||||||
},
|
},
|
||||||
base_branches: [] // target branches for the merged PR ignoring PRs with different target branch, by default it will get all PRs
|
base_branches: [] // target branches for the merged PR ignoring PRs with different target branch, by default it will get all PRs
|
||||||
};
|
};
|
||||||
@@ -891,6 +892,7 @@ const github = __importStar(__nccwpck_require__(5438));
|
|||||||
const semver = __importStar(__nccwpck_require__(1383));
|
const semver = __importStar(__nccwpck_require__(1383));
|
||||||
const semver_1 = __nccwpck_require__(1383);
|
const semver_1 = __nccwpck_require__(1383);
|
||||||
const gitHelper_1 = __nccwpck_require__(353);
|
const gitHelper_1 = __nccwpck_require__(353);
|
||||||
|
const transform_1 = __nccwpck_require__(1644);
|
||||||
class Tags {
|
class Tags {
|
||||||
constructor(octokit) {
|
constructor(octokit) {
|
||||||
this.octokit = octokit;
|
this.octokit = octokit;
|
||||||
@@ -973,7 +975,32 @@ class Tags {
|
|||||||
retrieveRange(repositoryPath, owner, repo, fromTag, toTag, ignorePreReleases, maxTagsToFetch, tagResolver) {
|
retrieveRange(repositoryPath, owner, repo, fromTag, toTag, ignorePreReleases, maxTagsToFetch, tagResolver) {
|
||||||
var _a;
|
var _a;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const tags = sortTags(yield this.getTags(owner, repo, maxTagsToFetch), tagResolver);
|
// filter out tags not matching the specified filter
|
||||||
|
const filteredTags = filterTags(
|
||||||
|
// retrieve the tags from the API
|
||||||
|
yield this.getTags(owner, repo, maxTagsToFetch), tagResolver);
|
||||||
|
// check if a transformer was defined
|
||||||
|
const tagTransformer = (0, transform_1.validateTransformer)(tagResolver.transformer);
|
||||||
|
let transformedTags;
|
||||||
|
if (tagTransformer != null) {
|
||||||
|
core.debug(`ℹ️ Using configured tagTransformer`);
|
||||||
|
transformedTags = transformTags(filteredTags, tagTransformer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
transformedTags = filteredTags;
|
||||||
|
}
|
||||||
|
let tags = sortTags(transformedTags, tagResolver);
|
||||||
|
if (tagTransformer != null) {
|
||||||
|
// restore the original name, after sorting
|
||||||
|
tags = filteredTags.map(function (tag) {
|
||||||
|
if (tag.hasOwnProperty('tmp')) {
|
||||||
|
return { name: tag.tmp, commit: tag.commit };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
let resultToTag;
|
let resultToTag;
|
||||||
let resultFromTag;
|
let resultFromTag;
|
||||||
// ensure to resolve the toTag if it was not provided
|
// ensure to resolve the toTag if it was not provided
|
||||||
@@ -1041,13 +1068,34 @@ function filterTags(tags, tagResolver) {
|
|||||||
const filter = tagResolver.filter;
|
const filter = tagResolver.filter;
|
||||||
if (filter !== undefined) {
|
if (filter !== undefined) {
|
||||||
const regex = new RegExp(filter.pattern.replace('\\\\', '\\'), (_a = filter.flags) !== null && _a !== void 0 ? _a : 'gu');
|
const regex = new RegExp(filter.pattern.replace('\\\\', '\\'), (_a = filter.flags) !== null && _a !== void 0 ? _a : 'gu');
|
||||||
return tags.filter(tag => tag.name.match(regex) !== null);
|
const filteredTags = tags.filter(tag => tag.name.match(regex) !== null);
|
||||||
|
core.debug(`ℹ️ Filtered tags count: ${filteredTags.length}, original count: ${tags.length}`);
|
||||||
|
return filteredTags;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.filterTags = filterTags;
|
exports.filterTags = filterTags;
|
||||||
|
/**
|
||||||
|
* Helper function to transform the tag name given the transformer
|
||||||
|
*/
|
||||||
|
function transformTags(tags, transformer) {
|
||||||
|
return tags.map(function (tag) {
|
||||||
|
if (transformer.pattern) {
|
||||||
|
const transformedName = tag.name.replace(transformer.pattern, transformer.target);
|
||||||
|
core.debug(`ℹ️ Transformed ${tag.name} to ${transformedName}`);
|
||||||
|
return {
|
||||||
|
tmp: tag.name,
|
||||||
|
name: transformedName,
|
||||||
|
commit: tag.commit
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
Sorts an array of tags as shown below:
|
Sorts an array of tags as shown below:
|
||||||
|
|
||||||
@@ -1142,7 +1190,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.fillAdditionalPlaceholders = exports.buildChangelog = void 0;
|
exports.validateTransformer = exports.fillAdditionalPlaceholders = exports.buildChangelog = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const configuration_1 = __nccwpck_require__(5527);
|
const configuration_1 = __nccwpck_require__(5527);
|
||||||
const pullRequests_1 = __nccwpck_require__(4217);
|
const pullRequests_1 = __nccwpck_require__(4217);
|
||||||
@@ -1345,15 +1393,18 @@ function validateTransformer(transformer) {
|
|||||||
try {
|
try {
|
||||||
let onProperty = undefined;
|
let onProperty = undefined;
|
||||||
let method = undefined;
|
let method = undefined;
|
||||||
|
let onEmpty = undefined;
|
||||||
if (transformer.hasOwnProperty('on_property')) {
|
if (transformer.hasOwnProperty('on_property')) {
|
||||||
onProperty = transformer.on_property;
|
onProperty = transformer.on_property;
|
||||||
method = transformer.method;
|
method = transformer.method;
|
||||||
|
onEmpty = transformer.on_empty;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
pattern: new RegExp(transformer.pattern.replace('\\\\', '\\'), (_a = transformer.flags) !== null && _a !== void 0 ? _a : 'gu'),
|
pattern: new RegExp(transformer.pattern.replace('\\\\', '\\'), (_a = transformer.flags) !== null && _a !== void 0 ? _a : 'gu'),
|
||||||
target: transformer.target || '',
|
target: transformer.target || '',
|
||||||
onProperty,
|
onProperty,
|
||||||
method
|
method,
|
||||||
|
onEmpty
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
@@ -1361,6 +1412,7 @@ function validateTransformer(transformer) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
exports.validateTransformer = validateTransformer;
|
||||||
function extractValues(pr, extractor, extractor_usecase) {
|
function extractValues(pr, extractor, extractor_usecase) {
|
||||||
if (extractor.pattern == null) {
|
if (extractor.pattern == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -1379,7 +1431,7 @@ function extractValues(pr, extractor, extractor_usecase) {
|
|||||||
}
|
}
|
||||||
if (extractor.method === 'match') {
|
if (extractor.method === 'match') {
|
||||||
const lables = onValue.match(extractor.pattern);
|
const lables = onValue.match(extractor.pattern);
|
||||||
if (lables !== null) {
|
if (lables !== null && lables.length > 0) {
|
||||||
return lables.map(label => label.toLocaleLowerCase('en'));
|
return lables.map(label => label.toLocaleLowerCase('en'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1389,6 +1441,9 @@ function extractValues(pr, extractor, extractor_usecase) {
|
|||||||
return [label.toLocaleLowerCase('en')];
|
return [label.toLocaleLowerCase('en')];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (extractor.onEmpty !== undefined) {
|
||||||
|
return [extractor.onEmpty.toLocaleLowerCase('en')];
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -34,11 +34,13 @@ export interface Transformer extends Regex {
|
|||||||
export interface Extractor extends Transformer {
|
export interface Extractor extends Transformer {
|
||||||
on_property?: 'title' | 'author' | 'milestone' | 'body' | undefined // retrieve the property to extract the value from
|
on_property?: 'title' | 'author' | 'milestone' | 'body' | undefined // retrieve the property to extract the value from
|
||||||
method?: 'replace' | 'match' | undefined // the method to use to extract the value, `match` will not use the `target` property
|
method?: 'replace' | 'match' | undefined // the method to use to extract the value, `match` will not use the `target` property
|
||||||
|
on_empty?: string | undefined // in case the regex results in an empty string, this value is gonna be used instead (only for label_extractor currently)
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TagResolver {
|
export interface TagResolver {
|
||||||
method: string // semver, sort
|
method: string // semver, sort
|
||||||
filter?: Regex // the regex to filter the tags
|
filter?: Regex // the regex to filter the tags, prior to sorting
|
||||||
|
transformer?: Transformer // transforms the tag name using the regex, run after the filter
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DefaultConfiguration: Configuration = {
|
export const DefaultConfiguration: Configuration = {
|
||||||
@@ -71,7 +73,8 @@ export const DefaultConfiguration: Configuration = {
|
|||||||
tag_resolver: {
|
tag_resolver: {
|
||||||
// defines the logic on how to resolve the previous tag, only relevant if `fromTag` is not specified
|
// defines the logic on how to resolve the previous tag, only relevant if `fromTag` is not specified
|
||||||
method: 'semver', // defines which method to use, by default it will use `semver` (dropping all non matching tags). Alternative `sort` is also available.
|
method: 'semver', // defines which method to use, by default it will use `semver` (dropping all non matching tags). Alternative `sort` is also available.
|
||||||
filter: undefined // filter out all tags not matching the regex
|
filter: undefined, // filter out all tags not matching the regex
|
||||||
|
transformer: undefined // transforms the tag name using the regex, run after the filter
|
||||||
},
|
},
|
||||||
base_branches: [] // target branches for the merged PR ignoring PRs with different target branch, by default it will get all PRs
|
base_branches: [] // target branches for the merged PR ignoring PRs with different target branch, by default it will get all PRs
|
||||||
}
|
}
|
||||||
|
|||||||
+62
-2
@@ -5,6 +5,7 @@ import {Octokit, RestEndpointMethodTypes} from '@octokit/rest'
|
|||||||
import {SemVer} from 'semver'
|
import {SemVer} from 'semver'
|
||||||
import {TagResolver} from './configuration'
|
import {TagResolver} from './configuration'
|
||||||
import {createCommandManager} from './gitHelper'
|
import {createCommandManager} from './gitHelper'
|
||||||
|
import {RegexTransformer, validateTransformer} from './transform'
|
||||||
|
|
||||||
export interface TagResult {
|
export interface TagResult {
|
||||||
from: TagInfo | null
|
from: TagInfo | null
|
||||||
@@ -16,6 +17,10 @@ export interface TagInfo {
|
|||||||
commit: string
|
commit: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SortableTagInfo extends TagInfo {
|
||||||
|
tmp: string
|
||||||
|
}
|
||||||
|
|
||||||
export class Tags {
|
export class Tags {
|
||||||
constructor(private octokit: Octokit) {}
|
constructor(private octokit: Octokit) {}
|
||||||
|
|
||||||
@@ -114,11 +119,37 @@ export class Tags {
|
|||||||
maxTagsToFetch: number,
|
maxTagsToFetch: number,
|
||||||
tagResolver: TagResolver
|
tagResolver: TagResolver
|
||||||
): Promise<TagResult> {
|
): Promise<TagResult> {
|
||||||
const tags = sortTags(
|
// filter out tags not matching the specified filter
|
||||||
|
const filteredTags = filterTags(
|
||||||
|
// retrieve the tags from the API
|
||||||
await this.getTags(owner, repo, maxTagsToFetch),
|
await this.getTags(owner, repo, maxTagsToFetch),
|
||||||
tagResolver
|
tagResolver
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// check if a transformer was defined
|
||||||
|
const tagTransformer = validateTransformer(tagResolver.transformer)
|
||||||
|
|
||||||
|
let transformedTags: TagInfo[]
|
||||||
|
if (tagTransformer != null) {
|
||||||
|
core.debug(`ℹ️ Using configured tagTransformer`)
|
||||||
|
transformedTags = transformTags(filteredTags, tagTransformer)
|
||||||
|
} else {
|
||||||
|
transformedTags = filteredTags
|
||||||
|
}
|
||||||
|
|
||||||
|
let tags = sortTags(transformedTags, tagResolver)
|
||||||
|
|
||||||
|
if (tagTransformer != null) {
|
||||||
|
// restore the original name, after sorting
|
||||||
|
tags = filteredTags.map(function (tag) {
|
||||||
|
if (tag.hasOwnProperty('tmp')) {
|
||||||
|
return {name: (tag as SortableTagInfo).tmp, commit: tag.commit}
|
||||||
|
} else {
|
||||||
|
return tag
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
let resultToTag: TagInfo | null
|
let resultToTag: TagInfo | null
|
||||||
let resultFromTag: TagInfo | null
|
let resultFromTag: TagInfo | null
|
||||||
|
|
||||||
@@ -205,12 +236,41 @@ export function filterTags(
|
|||||||
filter.pattern.replace('\\\\', '\\'),
|
filter.pattern.replace('\\\\', '\\'),
|
||||||
filter.flags ?? 'gu'
|
filter.flags ?? 'gu'
|
||||||
)
|
)
|
||||||
return tags.filter(tag => tag.name.match(regex) !== null)
|
const filteredTags = tags.filter(tag => tag.name.match(regex) !== null)
|
||||||
|
core.debug(
|
||||||
|
`ℹ️ Filtered tags count: ${filteredTags.length}, original count: ${tags.length}`
|
||||||
|
)
|
||||||
|
return filteredTags
|
||||||
} else {
|
} else {
|
||||||
return tags
|
return tags
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to transform the tag name given the transformer
|
||||||
|
*/
|
||||||
|
function transformTags(
|
||||||
|
tags: TagInfo[],
|
||||||
|
transformer: RegexTransformer
|
||||||
|
): TagInfo[] {
|
||||||
|
return tags.map(function (tag) {
|
||||||
|
if (transformer.pattern) {
|
||||||
|
const transformedName = tag.name.replace(
|
||||||
|
transformer.pattern,
|
||||||
|
transformer.target
|
||||||
|
)
|
||||||
|
core.debug(`ℹ️ Transformed ${tag.name} to ${transformedName}`)
|
||||||
|
return {
|
||||||
|
tmp: tag.name, // remember the original name
|
||||||
|
name: transformedName,
|
||||||
|
commit: tag.commit
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return tag
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sorts an array of tags as shown below:
|
Sorts an array of tags as shown below:
|
||||||
|
|
||||||
|
|||||||
+11
-4
@@ -293,7 +293,7 @@ function validateTransformers(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateTransformer(
|
export function validateTransformer(
|
||||||
transformer?: Transformer
|
transformer?: Transformer
|
||||||
): RegexTransformer | null {
|
): RegexTransformer | null {
|
||||||
if (transformer === undefined) {
|
if (transformer === undefined) {
|
||||||
@@ -302,9 +302,11 @@ function validateTransformer(
|
|||||||
try {
|
try {
|
||||||
let onProperty = undefined
|
let onProperty = undefined
|
||||||
let method = undefined
|
let method = undefined
|
||||||
|
let onEmpty = undefined
|
||||||
if (transformer.hasOwnProperty('on_property')) {
|
if (transformer.hasOwnProperty('on_property')) {
|
||||||
onProperty = (transformer as Extractor).on_property
|
onProperty = (transformer as Extractor).on_property
|
||||||
method = (transformer as Extractor).method
|
method = (transformer as Extractor).method
|
||||||
|
onEmpty = (transformer as Extractor).on_empty
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -314,7 +316,8 @@ function validateTransformer(
|
|||||||
),
|
),
|
||||||
target: transformer.target || '',
|
target: transformer.target || '',
|
||||||
onProperty,
|
onProperty,
|
||||||
method
|
method,
|
||||||
|
onEmpty
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
core.warning(`⚠️ Bad replacer regex: ${transformer.pattern}`)
|
core.warning(`⚠️ Bad replacer regex: ${transformer.pattern}`)
|
||||||
@@ -347,7 +350,7 @@ function extractValues(
|
|||||||
|
|
||||||
if (extractor.method === 'match') {
|
if (extractor.method === 'match') {
|
||||||
const lables = onValue.match(extractor.pattern)
|
const lables = onValue.match(extractor.pattern)
|
||||||
if (lables !== null) {
|
if (lables !== null && lables.length > 0) {
|
||||||
return lables.map(label => label.toLocaleLowerCase('en'))
|
return lables.map(label => label.toLocaleLowerCase('en'))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -356,12 +359,16 @@ function extractValues(
|
|||||||
return [label.toLocaleLowerCase('en')]
|
return [label.toLocaleLowerCase('en')]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (extractor.onEmpty !== undefined) {
|
||||||
|
return [extractor.onEmpty.toLocaleLowerCase('en')]
|
||||||
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RegexTransformer {
|
export interface RegexTransformer {
|
||||||
pattern: RegExp | null
|
pattern: RegExp | null
|
||||||
target: string
|
target: string
|
||||||
onProperty?: 'title' | 'author' | 'milestone' | 'body' | undefined
|
onProperty?: 'title' | 'author' | 'milestone' | 'body' | undefined
|
||||||
method?: 'replace' | 'match' | undefined
|
method?: 'replace' | 'match' | undefined
|
||||||
|
onEmpty?: string | undefined
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user