- expand custom assignment and add testcase to verify ability to construct custom categories involving states of PRs
This commit is contained in:
@@ -264,3 +264,30 @@ it('Verify default inclusion of open PRs', async () => {
|
||||
`## 🚀 Features\n\n- A feature to be going to v2 (nr3) (#3) merged\n- New feature to keep open (nr5) (#7) open\n\n\n\n\nUncategorized\n\n\n\nOpen\n- New feature to keep open (nr5) (#7) open\n`
|
||||
)
|
||||
})
|
||||
|
||||
it('Verify custom categorisation of open PRs', async () => {
|
||||
const configuration = resolveConfiguration(
|
||||
'',
|
||||
'configs_test/configuration_excluding_open.json'
|
||||
)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null, // baseUrl
|
||||
null, // token
|
||||
'.', // repoPath
|
||||
'mikepenz', // user
|
||||
'release-changelog-builder-action-playground', // repo
|
||||
'1.5.0', // fromTag
|
||||
'2.0.0', // toTag
|
||||
true, // includeOpen
|
||||
false, // failOnError
|
||||
false, // ignorePrePrelease
|
||||
false, // commitMode
|
||||
configuration // configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(
|
||||
`## 🚀 Features Merged\n\n- A feature to be going to v2 (nr3) -- (#3) [merged] {feature}\n\n## 🚀 Features Open\n\n- New feature to keep open (nr5) -- (#7) [open] {feature}\n\n`
|
||||
)
|
||||
})
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"categories": [
|
||||
{
|
||||
"title": "## 🚀 Features Merged",
|
||||
"labels": ["feature"],
|
||||
"exclude_labels": ["--rcba-open"]
|
||||
},
|
||||
{
|
||||
"title": "## 🚀 Features Open",
|
||||
"labels": ["feature", "--rcba-open"],
|
||||
"exhaustive": true
|
||||
}
|
||||
],
|
||||
"template": "${{CHANGELOG}}",
|
||||
"pr_template": "- ${{TITLE}} -- (#${{NUMBER}}) [${{STATUS}}] {${{LABELS}}}"
|
||||
}
|
||||
+4
-4
@@ -584,8 +584,8 @@ function sortPullRequests(pullRequests, ascending) {
|
||||
}
|
||||
exports.sortPullRequests = sortPullRequests;
|
||||
// helper function to add a special open label to prs not merged.
|
||||
function addOpenLabel(labels) {
|
||||
labels.add('##rcba-open');
|
||||
function attachSpeciaLabels(status, labels) {
|
||||
labels.add(`--rcba-${status}`);
|
||||
return labels;
|
||||
}
|
||||
const mapPullRequest = (pr, status = 'open') => {
|
||||
@@ -600,7 +600,7 @@ const mapPullRequest = (pr, status = 'open') => {
|
||||
mergeCommitSha: pr.merge_commit_sha || '',
|
||||
author: ((_a = pr.user) === null || _a === void 0 ? void 0 : _a.login) || '',
|
||||
repoName: pr.base.repo.full_name,
|
||||
labels: addOpenLabel(new Set(((_b = pr.labels) === null || _b === void 0 ? void 0 : _b.map(lbl => { var _a; return ((_a = lbl.name) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase('en')) || ''; })) || [])),
|
||||
labels: attachSpeciaLabels(status, new Set(((_b = pr.labels) === null || _b === void 0 ? void 0 : _b.map(lbl => { var _a; return ((_a = lbl.name) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase('en')) || ''; })) || [])),
|
||||
milestone: ((_c = pr.milestone) === null || _c === void 0 ? void 0 : _c.title) || '',
|
||||
body: pr.body || '',
|
||||
assignees: ((_d = pr.assignees) === null || _d === void 0 ? void 0 : _d.map(asignee => (asignee === null || asignee === void 0 ? void 0 : asignee.login) || '')) || [],
|
||||
@@ -1509,7 +1509,7 @@ function fillTemplate(pr, template) {
|
||||
transformed = transformed.replace(/\${{MERGED_AT}}/g, ((_a = pr.mergedAt) === null || _a === void 0 ? void 0 : _a.toISOString()) || '');
|
||||
transformed = transformed.replace(/\${{MERGE_SHA}}/g, pr.mergeCommitSha);
|
||||
transformed = transformed.replace(/\${{AUTHOR}}/g, pr.author);
|
||||
transformed = transformed.replace(/\${{LABELS}}/g, ((_c = (_b = [...pr.labels]) === null || _b === void 0 ? void 0 : _b.filter(l => !l.startsWith('##rcba-'))) === null || _c === void 0 ? void 0 : _c.join(', ')) || '');
|
||||
transformed = transformed.replace(/\${{LABELS}}/g, ((_c = (_b = [...pr.labels]) === null || _b === void 0 ? void 0 : _b.filter(l => !l.startsWith('--rcba-'))) === null || _c === void 0 ? void 0 : _c.join(', ')) || '');
|
||||
transformed = transformed.replace(/\${{MILESTONE}}/g, pr.milestone || '');
|
||||
transformed = transformed.replace(/\${{BODY}}/g, pr.body);
|
||||
transformed = transformed.replace(/\${{ASSIGNEES}}/g, ((_d = pr.assignees) === null || _d === void 0 ? void 0 : _d.join(', ')) || '');
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+7
-3
@@ -160,8 +160,11 @@ export function sortPullRequests(
|
||||
}
|
||||
|
||||
// helper function to add a special open label to prs not merged.
|
||||
function addOpenLabel(labels: Set<string>): Set<string> {
|
||||
labels.add('##rcba-open')
|
||||
function attachSpeciaLabels(
|
||||
status: 'open' | 'merged',
|
||||
labels: Set<string>
|
||||
): Set<string> {
|
||||
labels.add(`--rcba-${status}`)
|
||||
return labels
|
||||
}
|
||||
|
||||
@@ -178,7 +181,8 @@ const mapPullRequest = (
|
||||
mergeCommitSha: pr.merge_commit_sha || '',
|
||||
author: pr.user?.login || '',
|
||||
repoName: pr.base.repo.full_name,
|
||||
labels: addOpenLabel(
|
||||
labels: attachSpeciaLabels(
|
||||
status,
|
||||
new Set(
|
||||
pr.labels?.map(lbl => lbl.name?.toLocaleLowerCase('en') || '') || []
|
||||
)
|
||||
|
||||
+1
-1
@@ -323,7 +323,7 @@ function fillTemplate(pr: PullRequestInfo, template: string): string {
|
||||
transformed = transformed.replace(/\${{AUTHOR}}/g, pr.author)
|
||||
transformed = transformed.replace(
|
||||
/\${{LABELS}}/g,
|
||||
[...pr.labels]?.filter(l => !l.startsWith('##rcba-'))?.join(', ') || ''
|
||||
[...pr.labels]?.filter(l => !l.startsWith('--rcba-'))?.join(', ') || ''
|
||||
)
|
||||
transformed = transformed.replace(/\${{MILESTONE}}/g, pr.milestone || '')
|
||||
transformed = transformed.replace(/\${{BODY}}/g, pr.body)
|
||||
|
||||
Reference in New Issue
Block a user