Skip to content

Commit

Permalink
Merge pull request #1305 from mikepenz/develop
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
mikepenz committed Mar 1, 2024
2 parents 5f34097 + 225bc31 commit ef7f5f2
Show file tree
Hide file tree
Showing 7 changed files with 432 additions and 282 deletions.
67 changes: 66 additions & 1 deletion __tests__/tags.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {filterTags, prepareAndSortTags, TagInfo} from '../src/pr-collector/tags'
import { validateTransformer } from '../src/pr-collector/regexUtils'
import {filterTags, prepareAndSortTags, TagInfo, transformTags} from '../src/pr-collector/tags'

jest.setTimeout(180000)

Expand Down Expand Up @@ -114,3 +115,67 @@ it('Should filter tags correctly using the regex', async () => {

expect(filtered).toStrictEqual(`api-0.0.1,api-0.0.1-rc01,api-10.1.0-2`)
})

it('Should filter tags correctly using the regex (inverse)', 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: '^(?!\\w+-)(.+)',
flags: 'gu'
}
}
const filtered = filterTags(tags, tagResolver)
.map(function (tag) {
return tag.name
})
.join(',')

expect(filtered).toStrictEqual(`0.1.0-b01,1.0.0,1.0.0-a01,2.0.0,10.1.0,20.0.2`)
})


it('Should transform 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: '2.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',
transformer: {
pattern: '(api\-)?(.+)',
target: "$2"
}
}

const transformer = validateTransformer(tagResolver.transformer)
if(transformer != null) {
const transformed = transformTags(tags, transformer)
.map(function (tag) {
return tag.name
})
.join(',')

expect(transformed).toStrictEqual(`0.0.1,0.0.1-rc01,config-0.1.0,0.1.0-b01,2.0.0,10.1.0,10.1.0-2,20.0.2`)
}
})
57 changes: 41 additions & 16 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

0 comments on commit ef7f5f2

Please sign in to comment.