Skip to content

Commit

Permalink
Merge pull request #838 from mikepenz/develop
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
mikepenz authored Jul 29, 2022
2 parents f7134ad + f0807d2 commit ec65c47
Show file tree
Hide file tree
Showing 17 changed files with 446 additions and 581 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"printWidth": 80,
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": false,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ Table of supported placeholders allowed to be used in the `template` and `empty_
| `${{UNCATEGORIZED_COUNT}}` | The count of PRs and changes which were not categorized. No label overlapping with category labels | |
| `${{OPEN_COUNT}}` | The count of open PRs. Will only be fetched if `includeOpen` is configured. | |
| `${{IGNORED_COUNT}}` | The count of PRs and changes which were specifically ignored from the changelog. | |
| `${{DAYS_SINCE}}` | Days between the 2 releases. Requires `fetchReleaseInformation` to be enabled. | * |
| `${{DAYS_SINCE}}` | Days between the 2 releases. Requires `fetchReleaseInformation` to be enabled. | x |

### Configuration Specification

Expand Down
2 changes: 0 additions & 2 deletions __tests__/tags.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {resolveConfiguration} from '../src/utils'
import {ReleaseNotesBuilder} from '../src/releaseNotesBuilder'
import { TagInfo, sortTags, filterTags } from '../src/tags';

jest.setTimeout(180000)
Expand Down
52 changes: 46 additions & 6 deletions __tests__/transform.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {buildChangelog} from '../src/transform'
import {PullRequestInfo} from '../src/pullRequests'
import moment from 'moment'
import { DefaultConfiguration, Configuration } from '../src/configuration';
import { Configuration, DefaultConfiguration } from '../src/configuration';
import { DefaultDiffInfo } from '../src/commits';

jest.setTimeout(180000)
Expand Down Expand Up @@ -41,7 +41,7 @@ mergedPullRequests.push(
repoName: 'test-repo',
labels: new Set<string>(),
milestone: '',
body: 'no magic body for this matter',
body: 'no magic body1 for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
Expand All @@ -59,7 +59,7 @@ mergedPullRequests.push(
repoName: 'test-repo',
labels: new Set<string>(),
milestone: '',
body: 'no magic body for this matter',
body: 'no magic body2 for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
Expand All @@ -77,7 +77,7 @@ mergedPullRequests.push(
repoName: 'test-repo',
labels: new Set<string>(),
milestone: '',
body: 'no magic body for this matter',
body: 'no magic body3 for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
Expand All @@ -95,7 +95,7 @@ mergedPullRequests.push(
repoName: 'test-repo',
labels: new Set<string>(),
milestone: '',
body: 'no magic body for this matter',
body: 'no magic body4 for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
Expand Down Expand Up @@ -582,4 +582,44 @@ it('Use exclude labels to not include a PR within a category.', async () => {
expect(resultChangelog).toStrictEqual(
`## 🚀 Features and 🐛 Issues\n\n- [ABC-1234] - this is a PR 3 title message\n - PR: #3\n\n## 🚀 Features and/or 🐛 Issues But No 🐛 Fixes\n\n- [ABC-1234] - this is a PR 1 title message\n - PR: #1\n\n`
)
})
})


it('Extract custom placeholder from PR body and replace in global template', async () => {
const customConfig = Object.assign({}, configuration)
customConfig.custom_placeholders = [
{
name: "C_PLACEHOLDER_1",
source: "BODY",
transformer: {
pattern: '.+ (b....).+',
target: '- $1'
}
},
{
name: "C_PLACEHOLER_2",
source: "BODY",
transformer: {
pattern: '.+ b(....).+',
target: '\n- $1'
}
}
]
customConfig.template = "${{CHANGELOG}}\n\n${{C_PLACEHOLER_2[2]}}\n\n${{C_PLACEHOLER_2[*]}}${{C_PLACEHOLDER_1[7]}}${{C_PLACEHOLER_2[1493]}}"
customConfig.pr_template = "${{BODY}} ----> ${{C_PLACEHOLDER_1}}"

const resultChangelog = buildChangelog(DefaultDiffInfo, mergedPullRequests, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: { name: '1.0.0' },
toTag: { name: '2.0.0' },
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
commitMode: false,
configuration: customConfig
})

expect(resultChangelog).toStrictEqual(`## 🚀 Features\n\nno magic body1 for this matter ----> - body1\nno magic body3 for this matter ----> - body3\n\n## 🐛 Fixes\n\nno magic body2 for this matter ----> - body2\nno magic body3 for this matter ----> - body3\n\n## 🧪 Others\n\nno magic body4 for this matter ----> - body4\n\n\n\n\n- ody3\n\n\n- ody1\n- ody2\n- ody3\n- ody4`)
})
Loading

0 comments on commit ec65c47

Please sign in to comment.