@@ -166,7 +166,13 @@ This configuration is a `.json` file in the following format.
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "## 🧪 Tests",
|
"title": "## 🧪 Tests",
|
||||||
"labels": ["test"]
|
"labels": ["test"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "## 🧪 Tests and some 🪄 Magic",
|
||||||
|
"labels": ["test", "magic"],
|
||||||
|
"exclude_labels": ["no-magic"],
|
||||||
|
"exhaustive": true,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"ignore_labels": [
|
"ignore_labels": [
|
||||||
@@ -307,9 +313,10 @@ Table of descriptions for the `configuration.json` options to configure the resu
|
|||||||
|
|
||||||
| **Input** | **Description** |
|
| **Input** | **Description** |
|
||||||
|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| categories | An array of `category` specifications, offering a flexible way to group changes into categories |
|
| categories | An array of `category` specifications, offering a flexible way to group changes into categories. |
|
||||||
| category.title | The display name of a category in the changelog |
|
| category.title | The display name of a category in the changelog. |
|
||||||
| category.labels | An array of labels, to match pull request labels against. If any PR label matches any category label, the pull request will show up under this category |
|
| category.labels | An array of labels, to match pull request labels against. If any PR label matches any category label, the pull request will show up under this category. |
|
||||||
|
| category.exclude_labels | Similar to `labels`, an array of labels to match PRs against, but if a match occurs the PR is excluded from this category. |
|
||||||
| category.exhaustive | Will require all labels defined within this category to be present on the matching PR. |
|
| category.exhaustive | Will require all labels defined within this category to be present on the matching PR. |
|
||||||
| ignore_labels | An array of labels, to match pull request labels against. If any PR label overlaps, the pull request will be ignored from the changelog. This takes precedence over category labels |
|
| ignore_labels | An array of labels, to match pull request labels against. If any PR label overlaps, the pull request will be ignored from the changelog. This takes precedence over category labels |
|
||||||
| sort | The sort order of pull requests. [ASC, DESC] |
|
| sort | The sort order of pull requests. [ASC, DESC] |
|
||||||
|
|||||||
@@ -448,4 +448,41 @@ it('Release Diff', async () => {
|
|||||||
expect(resultChangelog).toStrictEqual(
|
expect(resultChangelog).toStrictEqual(
|
||||||
`https://github.com/mikepenz/release-changelog-builder-action/compare/v2.8.0...v2.8.1`
|
`https://github.com/mikepenz/release-changelog-builder-action/compare/v2.8.0...v2.8.1`
|
||||||
)
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
it('Use exclude labels to not include a PR within a category.', async () => {
|
||||||
|
const customConfig = Object.assign({}, DefaultConfiguration)
|
||||||
|
customConfig.categories = [
|
||||||
|
{
|
||||||
|
title: '## 🚀 Features and 🐛 Issues',
|
||||||
|
labels: ['Feature', 'Issue'],
|
||||||
|
exhaustive: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '## 🚀 Features and 🐛 Issues But No 🐛 Fixes',
|
||||||
|
labels: ['Feature', 'Issue'],
|
||||||
|
exclude_labels: ['Fix'],
|
||||||
|
exhaustive: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '## 🚀 Features and/or 🐛 Issues But No 🐛 Fixes',
|
||||||
|
labels: ['Feature', 'Issue'],
|
||||||
|
exclude_labels: ['Fix']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
const resultChangelog = buildChangelog(pullRequestsWithLabels, {
|
||||||
|
owner: 'mikepenz',
|
||||||
|
repo: 'test-repo',
|
||||||
|
fromTag: '1.0.0',
|
||||||
|
toTag: '2.0.0',
|
||||||
|
failOnError: false,
|
||||||
|
commitMode: false,
|
||||||
|
configuration: customConfig
|
||||||
|
})
|
||||||
|
|
||||||
|
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`
|
||||||
|
)
|
||||||
})
|
})
|
||||||
+12
@@ -1270,6 +1270,18 @@ function buildChangelog(prs, options) {
|
|||||||
}
|
}
|
||||||
let matched = false;
|
let matched = false;
|
||||||
for (const [category, pullRequests] of categorized) {
|
for (const [category, pullRequests] of categorized) {
|
||||||
|
// check if any exclude label matches
|
||||||
|
if (category.exclude_labels !== undefined) {
|
||||||
|
if (haveCommonElements(category.exclude_labels.map(lbl => lbl.toLocaleLowerCase('en')), pr.labels)) {
|
||||||
|
if (core.isDebug()) {
|
||||||
|
const prNum = pr.number;
|
||||||
|
const prLabels = pr.labels;
|
||||||
|
const excludeLabels = JSON.stringify(category.exclude_labels);
|
||||||
|
core.debug(`PR ${prNum} with labels: ${prLabels} excluded from category via exclude label: ${excludeLabels}`);
|
||||||
|
}
|
||||||
|
continue; // one of the exclude labels matched, skip the PR for this category
|
||||||
|
}
|
||||||
|
}
|
||||||
if (category.exhaustive === true) {
|
if (category.exhaustive === true) {
|
||||||
if (haveEveryElements(category.labels.map(lbl => lbl.toLocaleLowerCase('en')), pr.labels)) {
|
if (haveEveryElements(category.labels.map(lbl => lbl.toLocaleLowerCase('en')), pr.labels)) {
|
||||||
pullRequests.push(body);
|
pullRequests.push(body);
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+861
-775
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -43,14 +43,14 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.4.0",
|
"@types/jest": "^27.4.0",
|
||||||
"@typescript-eslint/parser": "^5.10.2",
|
"@typescript-eslint/parser": "^5.11.0",
|
||||||
"@types/node": "^17.0.14",
|
"@types/node": "^17.0.17",
|
||||||
"@vercel/ncc": "^0.33.1",
|
"@vercel/ncc": "^0.33.1",
|
||||||
"eslint": "^8.8.0",
|
"eslint": "^8.8.0",
|
||||||
"eslint-plugin-github": "^4.3.5",
|
"eslint-plugin-github": "^4.3.5",
|
||||||
"eslint-plugin-jest": "^26.0.0",
|
"eslint-plugin-jest": "^26.1.0",
|
||||||
"jest": "^27.4.7",
|
"jest": "^27.5.1",
|
||||||
"jest-circus": "^27.4.6",
|
"jest-circus": "^27.5.1",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"prettier": "2.5.1",
|
"prettier": "2.5.1",
|
||||||
"ts-jest": "^27.1.3",
|
"ts-jest": "^27.1.3",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export interface Configuration {
|
|||||||
export interface Category {
|
export interface Category {
|
||||||
title: string // the title of this category
|
title: string // the title of this category
|
||||||
labels: string[] // labels to associate PRs to this category
|
labels: string[] // labels to associate PRs to this category
|
||||||
|
exclude_labels?: string[] // if an exclude label is detected, the PR will be excluded from this category
|
||||||
exhaustive?: boolean // requires all labels to be present in the PR
|
exhaustive?: boolean // requires all labels to be present in the PR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,26 @@ export function buildChangelog(
|
|||||||
|
|
||||||
let matched = false
|
let matched = false
|
||||||
for (const [category, pullRequests] of categorized) {
|
for (const [category, pullRequests] of categorized) {
|
||||||
|
// check if any exclude label matches
|
||||||
|
if (category.exclude_labels !== undefined) {
|
||||||
|
if (
|
||||||
|
haveCommonElements(
|
||||||
|
category.exclude_labels.map(lbl => lbl.toLocaleLowerCase('en')),
|
||||||
|
pr.labels
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
if (core.isDebug()) {
|
||||||
|
const prNum = pr.number
|
||||||
|
const prLabels = pr.labels
|
||||||
|
const excludeLabels = JSON.stringify(category.exclude_labels)
|
||||||
|
core.debug(
|
||||||
|
`PR ${prNum} with labels: ${prLabels} excluded from category via exclude label: ${excludeLabels}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
continue // one of the exclude labels matched, skip the PR for this category
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (category.exhaustive === true) {
|
if (category.exhaustive === true) {
|
||||||
if (
|
if (
|
||||||
haveEveryElements(
|
haveEveryElements(
|
||||||
|
|||||||
Reference in New Issue
Block a user