- add new ability to filter out tags based on a regex

- FIX https://github.com/mikepenz/release-changelog-builder-action/issues/566
This commit is contained in:
Mike Penz
2021-11-05 08:52:21 +01:00
parent 431f48dd0f
commit ed954db1f6
6 changed files with 89 additions and 9 deletions
+34 -1
View File
@@ -1,6 +1,6 @@
import {resolveConfiguration} from '../src/utils'
import {ReleaseNotesBuilder} from '../src/releaseNotesBuilder'
import {TagInfo, sortTags} from '../src/tags'
import { TagInfo, sortTags, filterTags } from '../src/tags';
jest.setTimeout(180000)
@@ -91,3 +91,36 @@ it('Should order tags alphabetical', async () => {
`a,20.0.2,2.0.0,1000.0.0,10.1.0,10.1.0-2,10.0.0,1.0.0,1.0.0-a01,v1,0.1.0-b01,0.0.1,0.0.1-rc01`
)
})
it('Should filter tags correctly using the regex', async () => {
const tags: TagInfo[] = [
{name: 'api-0.0.1', commit: ''},
{name: 'api-0.0.1-rc01', commit: ''},
{name: 'config-0.1.0', commit: ''},
{name: '0.1.0-b01', commit: ''},
{name: '1.0.0', commit: ''},
{name: '1.0.0-a01', commit: ''},
{name: '2.0.0', commit: ''},
{name: 'ap-10.0.0', commit: ''},
{name: '10.1.0', commit: ''},
{name: 'api-10.1.0-2', commit: ''},
{name: '20.0.2', commit: ''}
]
const tagResolver = {
method: 'non-existing-method',
filter: {
"pattern": "api-(.+)",
"flags": "gu"
}
}
const filtered = filterTags(tags, tagResolver)
.map(function (tag) {
return tag.name
})
.join(',')
expect(filtered).toStrictEqual(
`api-0.0.1,api-0.0.1-rc01,api-10.1.0-2`
)
})