Merge pull request #85 from mikepenz/feature/unlabelled_category

Introduce config support to have a `uncategorized` category for all PRs not matching a label
This commit is contained in:
Mike Penz
2020-11-04 14:20:52 +01:00
committed by GitHub
5 changed files with 53 additions and 4 deletions
+22
View File
@@ -109,4 +109,26 @@ it('Should fill `template` placeholders, ignore', async () => {
const changeLog = await releaseNotesBuilder.build()
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🚀 Features\n\n- Enhance sorting by using proper semver\n - PR: #51\n\n## 🧪 Tests\n\n- Improve test cases\n - PR: #49\n\n\n- Bump @types/node from 14.11.8 to 14.11.10\n - PR: #47\n- Adjust code to move fromTag resolving to main.ts\n - PR: #48\n- dev -> main\n - PR: #52\n- Update package.json to updated description\n - PR: #53\n- dev -> main\n - PR: #54\n\n- New additional placeholders for \`template\` and \`empty_template\`\n - PR: #50\n\nmikepenz\nrelease-changelog-builder-action\nv0.9.1\nv0.9.5\n2\n5\n1`)
})
it('Uncategorized category', async () => {
jest.setTimeout(180000)
const configuration = resolveConfiguration('', 'configs_test/configuration_uncategorized_category.json')
const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
'.',
'mikepenz',
'release-changelog-builder-action',
'v0.9.1',
'v0.9.5',
false,
false,
configuration
)
const changeLog = await releaseNotesBuilder.build()
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🚀 Features\n\n- Enhance sorting by using proper semver\n - PR: #51\n\n## 📦 Uncategorized\n\n- Bump @types/node from 14.11.8 to 14.11.10\n - PR: #47\n- Adjust code to move fromTag resolving to main.ts\n - PR: #48\n- Improve test cases\n - PR: #49\n- dev -> main\n - PR: #52\n- Update package.json to updated description\n - PR: #53\n- dev -> main\n - PR: #54\n\n\n\nUncategorized:\n- Bump @types/node from 14.11.8 to 14.11.10\n - PR: #47\n- Adjust code to move fromTag resolving to main.ts\n - PR: #48\n- Improve test cases\n - PR: #49\n- dev -> main\n - PR: #52\n- Update package.json to updated description\n - PR: #53\n- dev -> main\n - PR: #54\n\n\nIgnored:\n- New additional placeholders for \`template\` and \`empty_template\`\n - PR: #50\n\n\n6\n1`)
})
@@ -0,0 +1,14 @@
{
"categories": [
{
"title": "## 🚀 Features",
"labels": ["feature"]
},
{
"title": "## 📦 Uncategorized",
"labels": []
}
],
"template": "${{CHANGELOG}}\n\nUncategorized:\n${{UNCATEGORIZED}}\n\nIgnored:\n${{IGNORED}}\n\n${{UNCATEGORIZED_COUNT}}\n${{IGNORED_COUNT}}",
"empty_template": "${{OWNER}}\n${{REPO}}\n${{FROM_TAG}}\n${{TO_TAG}}"
}
Generated Vendored
+7 -1
View File
@@ -1027,10 +1027,16 @@ function buildChangelog(prs, config, options) {
if (haveCommonElements(category.labels, pr.labels)) {
pullRequests.push(body);
matched = true;
break;
}
}
if (!matched) {
// we allow to have pull requests included in an "uncategorized" category
for (const [category, pullRequests] of categorized) {
if (category.labels.length == 0) {
pullRequests.push(body);
break;
}
}
uncategorizedPrs.push(body);
}
else {
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+9 -2
View File
@@ -64,11 +64,18 @@ export function buildChangelog(
if (haveCommonElements(category.labels, pr.labels)) {
pullRequests.push(body)
matched = true
break
}
}
if (!matched) {
// we allow to have pull requests included in an "uncategorized" category
for (const [category, pullRequests] of categorized) {
if (category.labels.length === 0) {
pullRequests.push(body)
break
}
}
uncategorizedPrs.push(body)
} else {
categorizedPrs.push(body)