Skip to content

Commit

Permalink
Merge pull request #656 from mikepenz/develop
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
mikepenz authored Jan 28, 2022
2 parents af85373 + b37e20c commit bfe1f0e
Show file tree
Hide file tree
Showing 8 changed files with 500 additions and 217 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,14 @@ Table of descriptions for the `configuration.json` options to configure the resu
# Install the dependencies
$ npm install
# Verify lint is happy
$ npm run lint -- --fix
# Build the typescript and package it for distribution
$ npm run build && npm run package
# Run the tests, use to debug, and test it out
$ npm test
# Verify lint is happy
$ npm run lint -- --fix
```

It's suggested to export the token to your path before running the tests so that API calls can be done to GitHub.
Expand Down
43 changes: 43 additions & 0 deletions __tests__/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ mergedPullRequests.push(
}
)

const pullRequestWithLabelInBody: PullRequestInfo = {
number: 5,
title: 'label in body',
htmlURL: '',
baseBranch: '',
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
repoName: 'test-repo',
labels: new Set<string>(),
milestone: '',
body: '[Issue][Feature][AB-1234321] - no magic body for this matter',
assignees: [],
requestedReviewers: []
}

it('Extract label from title, combined regex', async () => {
configuration.label_extractor = [
{
Expand All @@ -114,6 +130,33 @@ it('Extract label from title, combined regex', async () => {
)
})


it('Extract label from title and body, combined regex', async () => {
configuration.label_extractor = [
{
pattern: '.*(\\[Feature\\]|\\[Issue\\]).*',
target: '$1',
on_property: ['title', 'body']
}
]

let prs = Array.from(mergedPullRequests)
prs.push(pullRequestWithLabelInBody)
const resultChangelog = buildChangelog(prs, {
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- label in body\n - PR: #5\n\n## 🐛 Fixes\n\n- [Issue][AB-4321] - this is a PR 2 title message\n - PR: #2\n\n`
)
})

it('Extract label from title, split regex', async () => {
configuration.label_extractor = [
{
Expand Down
70 changes: 58 additions & 12 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.

Loading

0 comments on commit bfe1f0e

Please sign in to comment.