Merge pull request #1440 from mikepenz/develop

dev -> main
This commit is contained in:
Mike Penz
2025-02-19 17:10:38 +01:00
committed by GitHub
26 changed files with 6011 additions and 3915 deletions
+17
View File
@@ -525,6 +525,21 @@ Similar to `REVIEWS`, `REFERENCED` PRs also offer special placeholders.
</p>
</details>
### Commit Template placeholders
Table of supported placeholders allowed to be used in the `commit_template` configuration, which will be included in the release notes / changelog. Applies to `HYBRID` and `COMMIT` modes only.
| **Placeholder** | **Description** |
|--------------------|----------------------------------------------------------------------------------------------------|
| `#{{NUMBER}}` | Always 0. |
| `#{{TITLE}}` | The commit summary. |
| `#{{STATUS}}` | Always `merged`. |
| `#{{CREATED_AT}}` | The ISO time of the commit. |
| `#{{MERGE_SHA}}` | The commit SHA. |
| `#{{AUTHOR}}` | The username of the commit Author. |
| `#{{AUTHOR_NAME}}` | The name of the commit Author (Can be empty). |
| `#{{BODY}}` | The commit message. |
### Configuration Specification
Table of descriptions for the `configuration.json` options to configure the resulting release notes / changelog.
@@ -543,12 +558,14 @@ Table of descriptions for the `configuration.json` options to configure the resu
| category.rules.pattern | A `regex` pattern to match the property value towards. Uses `RegExp.test("val")` |
| category.rules.flags | Defines the regex flags specified for the pattern. Default: `gu`. |
| category.rules.on_property | The PR property to match against. [Possible values](https://github.com/mikepenz/release-changelog-builder-action/blob/develop/src/configuration.ts#L33-L43). |
| category.mode | Defines if this category applies to PRs, commits or both. Allowed values: `PR`, `COMMIT`, `HYBRID`. Default: `HYBRID`. |
| 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 | A `sort` specification, offering the ability to define sort order and property. |
| sort.order | The sort order. Allowed values: `ASC`, `DESC` |
| sort.on_property | The property to sort on. Allowed values: `mergedAt`, `title` |
| template | Specifies the global template to pick for creating the changelog. See [Template placeholders](#template-placeholders) for possible values |
| pr_template | Defines the per pull request template. See [PR Template placeholders](#pr-template-placeholders) for possible values |
| commit_template | Defines the per commit template. Used in `HYBRID` and `COMMIT` modes only. If empty, uses the template defined for `pr_template`. See [Commit Template placeholders](#commit-template-placeholders) for possible values. |
| empty_template | Template to pick if no changes are detected. See [Template placeholders](#template-placeholders) for possible values |
| label_extractor.\[{\<EXTRACTOR\>}\] | An array of `Extractor` specifications, offering a flexible API to extract additional labels from a PR. Please see the documentation related to [Regex Configuration](#regex-configuration) for more details. |
| duplicate_filter.{\<EXTRACTOR\>} | Defines the `Extractor` to use for retrieving the identifier for a PR. In case of duplicates will keep the last matching pull request (depends on `sort`). Please see the documentation related to [Regex Configuration](#regex-configuration) for more details. |
+47 -5
View File
@@ -1,6 +1,6 @@
import {mergeConfiguration, parseConfiguration, resolveConfiguration} from '../src/utils.js'
import { clear } from "../src/transform.js";
import {clear} from '../src/transform.js'
import {jest} from '@jest/globals'
jest.setTimeout(180000)
clear()
@@ -15,8 +15,50 @@ it('Configurations are merged correctly', async () => {
const mergedConfiguration = mergeConfiguration(configurationJson, configurationFile)
console.log(mergedConfiguration)
expect(JSON.stringify(mergedConfiguration)).toEqual(
`{\"max_tags_to_fetch\":200,\"max_pull_requests\":1000,\"max_back_track_time_days\":1000,\"exclude_merge_branches\":[],\"sort\":\"DESC\",\"template\":\"#\{\{CHANGELOG}}\",\"pr_template\":\"- #\{\{TITLE}}\\n - PR: ##\{\{NUMBER}}\",\"empty_template\":\"- no magic changes\",\"categories\":[{\"title\":\"## 🚀 Features\",\"labels\":[\"feature\"]},{\"title\":\"## 🐛 Fixes\",\"labels\":[\"fix\"]},{\"title\":\"## 🧪 Tests\",\"labels\":[\"test\"]}],\"ignore_labels\":[\"ignore\"],\"label_extractor\":[],\"transformers\":[],\"tag_resolver\":{\"method\":\"semver\"},\"base_branches\":[],\"custom_placeholders\":[],\"trim_values\":true}`
const expectedStringified = JSON.stringify(mergedConfiguration, null, 2)
expect(expectedStringified).toEqual(
`{
"max_tags_to_fetch": 200,
"max_pull_requests": 1000,
"max_back_track_time_days": 1000,
"exclude_merge_branches": [],
"sort": "DESC",
"template": "#{{CHANGELOG}}",
"pr_template": "- #{{TITLE}}\\n - PR: ##{{NUMBER}}",
"commit_template": "- #{{TITLE}}",
"empty_template": "- no magic changes",
"categories": [
{
"title": "## 🚀 Features",
"labels": [
"feature"
]
},
{
"title": "## 🐛 Fixes",
"labels": [
"fix"
]
},
{
"title": "## 🧪 Tests",
"labels": [
"test"
]
}
],
"ignore_labels": [
"ignore"
],
"label_extractor": [],
"transformers": [],
"tag_resolver": {
"method": "semver"
},
"base_branches": [],
"custom_placeholders": [],
"trim_values": true
}`
)
})
+1
View File
@@ -1,6 +1,7 @@
import {mergeConfiguration, resolveConfiguration} from '../../src/utils.js'
import {ReleaseNotesBuilder} from '../../src/releaseNotesBuilder.js'
import {GithubRepository} from '../../src/repositories/GithubRepository.js'
import {jest} from '@jest/globals'
jest.setTimeout(180000)
@@ -2,6 +2,7 @@ import {mergeConfiguration, resolveConfiguration} from '../../src/utils.js'
import {ReleaseNotesBuilder} from '../../src/releaseNotesBuilder.js'
import {GiteaRepository} from '../../src/repositories/GiteaRepository.js'
import {clear} from '../../src/transform.js'
import {jest} from '@jest/globals'
jest.setTimeout(180000)
clear()
@@ -4,6 +4,7 @@ import {Options, pullData} from '../../src/pr-collector/prCollector.js'
import {GiteaRepository} from '../../src/repositories/GiteaRepository.js'
import {clear} from '../../src/transform.js'
import {ReleaseNotesOptions} from '../../src/releaseNotesBuilder.js'
import {jest} from '@jest/globals'
jest.setTimeout(180000)
clear()
+5
View File
@@ -3,10 +3,15 @@ import * as process from 'process'
import * as cp from 'child_process'
import * as fs from 'fs'
import {clear} from '../src/transform.js'
import {jest} from '@jest/globals'
import { fileURLToPath } from 'url';
jest.setTimeout(180000)
clear()
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
const __dirname = path.dirname(__filename); // get the name of the directory
test('missing values should result in failure', () => {
expect.assertions(1)
+1
View File
@@ -1,6 +1,7 @@
import {transformStringToValue, validateRegex} from '../src/pr-collector/regexUtils.js'
import {Regex} from '../src/pr-collector/types.js'
import {clear} from '../src/transform.js'
import {jest} from '@jest/globals'
jest.setTimeout(180000)
clear()
+1
View File
@@ -2,6 +2,7 @@ import {mergeConfiguration, resolveConfiguration} from '../src/utils.js'
import {ReleaseNotesBuilder} from '../src/releaseNotesBuilder.js'
import {GithubRepository} from '../src/repositories/GithubRepository.js'
import {clear} from '../src/transform.js'
import {jest} from '@jest/globals'
jest.setTimeout(180000)
clear()
+184 -1
View File
@@ -4,6 +4,7 @@ import {Options, pullData} from '../src/pr-collector/prCollector.js'
import {GithubRepository} from '../src/repositories/GithubRepository.js'
import {clear} from '../src/transform.js'
import {ReleaseNotesOptions} from '../src/releaseNotesBuilder.js'
import {jest} from '@jest/globals'
jest.setTimeout(180000)
clear()
@@ -366,7 +367,7 @@ it('Default configuration with commit mode', async () => {
it('Default configuration with commit mode and custom placeholder', async () => {
const configuration = Object.assign({}, mergeConfiguration(undefined, undefined, 'COMMIT'))
configuration.pr_template = '- #{{TITLE_ONLY}}'
configuration.commit_template = '- #{{TITLE_ONLY}}'
configuration.trim_values = true
configuration.custom_placeholders = [
{
@@ -407,3 +408,185 @@ it('Default configuration with commit mode and custom placeholder', async () =>
`## 🚀 Features\n\n- add Bengali\n- add uzbek translation (#558)\n\n## 🐛 Fixes\n\n- Fix grammar and consistency in french translation (#546)\n- fix typo\n- Distinguish translations of 'Release/Publish'\n- fix translation typo for message (#567)\n\n## 📦 Other\n\n- new thi.ng links and descriptions\n- add link to git-changelog-command-line docker image\n- Add descriptions for commit types`
)
})
it('Default configuration with hybrid mode and classic categories', async () => {
const configuration = Object.assign({}, mergeConfiguration(undefined, undefined, 'HYBRID'))
const options = {
owner: 'conventional-commits',
repo: 'conventionalcommits.org',
fromTag: {name: '56cdc85d01fd11aa164bd958bbf6114a51abfcf6'},
toTag: {name: '325b74fbc44bf34d9fa645951d076a450b4e26be'},
includeOpen: false,
failOnError: false,
fetchViaCommits: false,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
mode: 'HYBRID',
configuration,
repositoryUtils: githubRepository
} as ReleaseNotesOptions & Options
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/github_conventional-hybrid-1e1c8e-325b74.json')
}
const releaseNotesOptions = {...options, ...(data?.options ? data.options : {})} as unknown as ReleaseNotesOptions
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, releaseNotesOptions)
console.log(changeLog)
const expected = `## 🚀 Features
- feat(lang): add Bengali
- feat(lang): add uzbek translation (#558)
## 🐛 Fixes
- fix: Fix grammar and consistency in french translation (#546)
- fix(ja): fix typo
- fix(zh-hant): Distinguish translations of 'Release/Publish'
- fix(ko): fix translation typo for message (#567)
## 📦 Other
- fix: Fix grammar and consistency in french translation
- Add/update tool/project links
- fix(ja): fix typo
- docs: add link to git-changelog-command-line docker image
- docs: Add descriptions for commit types
- fix(zh-hant): Distinguish translations of 'Release/Publish'
- "feat(lang): add Bengali translation"
- feat(lang): add uzbek translation
- fix(ko): fix translation typo for message
- doc: new thi.ng links and descriptions
- docs: add link to git-changelog-command-line docker image
- docs: Add descriptions for commit types
`
expect(changeLog).toStrictEqual(expected)
})
it('Default configuration with hybrid mode and with separate feature categories', async () => {
const configuration = Object.assign({}, mergeConfiguration(undefined, undefined, 'HYBRID'))
const options = {
owner: 'conventional-commits',
repo: 'conventionalcommits.org',
fromTag: {name: '56cdc85d01fd11aa164bd958bbf6114a51abfcf6'},
toTag: {name: '325b74fbc44bf34d9fa645951d076a450b4e26be'},
includeOpen: false,
failOnError: false,
fetchViaCommits: false,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
mode: 'HYBRID',
configuration,
repositoryUtils: githubRepository
} as ReleaseNotesOptions & Options
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/github_conventional-hybrid-separate-cats-1e1c8e-325b74.json')
}
const releaseNotesOptions = {...options, ...(data?.options ? data.options : {})} as unknown as ReleaseNotesOptions
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, releaseNotesOptions)
console.log(changeLog)
const expected = `## 🚀 Big features
- feat(lang): add uzbek translation
## 🚀 Small features
- feat(lang): add Bengali
- feat(lang): add uzbek translation (#558)
## 🐛 Fixes
- fix: Fix grammar and consistency in french translation
- fix(ja): fix typo
- fix(zh-hant): Distinguish translations of 'Release/Publish'
- fix(ko): fix translation typo for message
- fix: Fix grammar and consistency in french translation (#546)
- fix(ja): fix typo
- fix(zh-hant): Distinguish translations of 'Release/Publish'
- fix(ko): fix translation typo for message (#567)
## 📦 Other
- Add/update tool/project links
- docs: add link to git-changelog-command-line docker image
- docs: Add descriptions for commit types
- "feat(lang): add Bengali translation"
- doc: new thi.ng links and descriptions
- docs: add link to git-changelog-command-line docker image
- docs: Add descriptions for commit types
`
expect(changeLog).toStrictEqual(expected)
})
it('Default configuration with hybrid mode and with separate feature categories and dup checker', async () => {
const configuration = Object.assign({}, mergeConfiguration(undefined, undefined, 'HYBRID'))
const options = {
owner: 'conventional-commits',
repo: 'conventionalcommits.org',
fromTag: {name: '56cdc85d01fd11aa164bd958bbf6114a51abfcf6'},
toTag: {name: '325b74fbc44bf34d9fa645951d076a450b4e26be'},
includeOpen: false,
failOnError: false,
fetchViaCommits: false,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
mode: 'HYBRID',
configuration,
repositoryUtils: githubRepository
} as ReleaseNotesOptions & Options
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/github_conventional-hybrid-separate-cats-1e1c8e-325b74.json')
}
const releaseNotesOptions = {...options, ...(data?.options ? data.options : {})} as unknown as ReleaseNotesOptions
releaseNotesOptions.configuration.duplicate_filter = {
pattern: '(.+) \\(#\\d+\\)',
target: '$1',
on_property: 'title'
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, releaseNotesOptions)
console.log(changeLog)
// Test author's note: Here I was hoping the "add uzbek translation" pr would be categorized
// as a Big feature, but due to how duplicates are handled (i.e. previous ones get replaced by following duplicates)
// it ends up as a Small feature. I'm not sure if this is the desired behavior or not, but I'm leaving it as is for now.
const expected = `## 🚀 Small features
- feat(lang): add Bengali
- feat(lang): add uzbek translation (#558)
## 🐛 Fixes
- fix: Fix grammar and consistency in french translation
- fix(ja): fix typo
- fix(zh-hant): Distinguish translations of 'Release/Publish'
- fix(ko): fix translation typo for message (#567)
## 📦 Other
- Add/update tool/project links
- "feat(lang): add Bengali translation"
- doc: new thi.ng links and descriptions
- docs: add link to git-changelog-command-line docker image
- docs: Add descriptions for commit types
`
expect(changeLog).toStrictEqual(expected)
})
+1
View File
@@ -2,6 +2,7 @@ import {TagResolver} from '../src/configuration.js'
import {validateRegex} from '../src/pr-collector/regexUtils.js'
import {filterTags, prepareAndSortTags, TagInfo, transformTags} from '../src/pr-collector/tags.js'
import {clear} from '../src/transform.js'
import {jest} from '@jest/globals'
jest.setTimeout(180000)
clear()
+27 -4
View File
@@ -1,15 +1,33 @@
import {buildChangelog} from '../src/transform.js'
import moment from 'moment'
import {DefaultConfiguration} from '../src/configuration.js'
import {Configuration, DefaultConfiguration} from '../src/configuration.js'
import {PullRequestInfo} from '../src/pr-collector/pullRequests.js'
import {DefaultDiffInfo} from '../src/pr-collector/commits.js'
import {GithubRepository} from '../src/repositories/GithubRepository.js'
import {clear} from '../src/transform.js'
import { buildChangelogTest } from "./utils.js";
import {jest} from '@jest/globals'
import {BaseRepository} from '../src/repositories/BaseRepository.js'
jest.setTimeout(180000)
clear()
const buildChangelogTest = (config: Configuration, prs: PullRequestInfo[], repositoryUtils: BaseRepository): string => {
return buildChangelog(DefaultDiffInfo, prs, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: {name: '1.0.0'},
toTag: {name: '2.0.0'},
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
mode: 'PR',
configuration: config,
repositoryUtils
})
}
const configuration = Object.assign({}, DefaultConfiguration)
configuration.categories = [
{
@@ -459,9 +477,14 @@ const repositoryUtils = new GithubRepository(process.env.GITEA_TOKEN || '', unde
it('Commit SHA-1 in commitMode', async () => {
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.sort = 'DESC'
customConfig.pr_template = '#{{MERGE_SHA}}'
customConfig.commit_template = '#{{MERGE_SHA}}'
const resultChangelog = buildChangelog(DefaultDiffInfo, pullRequestsWithLabels, {
// Since this is COMMIT mode, the prs would have been built with "number: 0"
const convertedPrs = pullRequestsWithLabels.map(pr => {
return {...pr, number: 0}
})
const resultChangelog = buildChangelog(DefaultDiffInfo, convertedPrs, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: {name: '1.0.0'},
+42 -3
View File
@@ -1,15 +1,54 @@
import moment from 'moment'
import {DefaultConfiguration} from '../src/configuration.js'
import {Configuration, DefaultConfiguration} from '../src/configuration.js'
import {PullRequestInfo} from '../src/pr-collector/pullRequests.js'
import {GithubRepository} from '../src/repositories/GithubRepository.js'
import {clear} from '../src/transform.js'
import {buildChangelogTest, buildPullRequeset} from './utils.js'
import {buildChangelog, clear} from '../src/transform.js'
import {jest} from '@jest/globals'
import {BaseRepository} from '../src/repositories/BaseRepository.js'
import {DefaultDiffInfo} from '../src/pr-collector/commits.js'
jest.setTimeout(180000)
clear()
const repositoryUtils = new GithubRepository(process.env.GITEA_TOKEN || '', undefined, '.')
const buildChangelogTest = (config: Configuration, prs: PullRequestInfo[], repositoryUtils: BaseRepository): string => {
return buildChangelog(DefaultDiffInfo, prs, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: {name: '1.0.0'},
toTag: {name: '2.0.0'},
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
mode: 'PR',
configuration: config,
repositoryUtils
})
}
const buildPullRequeset = (number: number, title: string, labels: string[] = ['feature']): PullRequestInfo => {
return {
number,
title,
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha',
author: 'Author',
authorName: 'Author',
repoName: 'test-repo',
labels,
milestone: '',
body: '',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: 'merged'
}
}
// test set of PRs with lables predefined
const pullRequestsWithLabels: PullRequestInfo[] = []
pullRequestsWithLabels.push(
-45
View File
@@ -1,45 +0,0 @@
import {Configuration} from '../src/configuration.js'
import {DefaultDiffInfo} from '../src/pr-collector/commits.js'
import {PullRequestInfo} from '../src/pr-collector/pullRequests.js'
import {buildChangelog} from '../src/transform.js'
import {BaseRepository} from '../src/repositories/BaseRepository.js'
import moment from 'moment'
export const buildChangelogTest = (config: Configuration, prs: PullRequestInfo[], repositoryUtils: BaseRepository): string => {
return buildChangelog(DefaultDiffInfo, prs, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: {name: '1.0.0'},
toTag: {name: '2.0.0'},
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
mode: 'PR',
configuration: config,
repositoryUtils
})
}
export const buildPullRequeset = (number: number, title: string, labels: string[] = ['feature']): PullRequestInfo => {
return {
number,
title,
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha',
author: 'Author',
authorName: 'Author',
repoName: 'test-repo',
labels,
milestone: '',
body: '',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: 'merged'
}
}
@@ -0,0 +1,470 @@
{
"mergedPullRequests": [
{
"number": 546,
"title": "fix: Fix grammar and consistency in french translation",
"htmlURL": "https://github.com/conventional-commits/conventionalcommits.org/pull/546",
"baseBranch": "master",
"branch": "patch-1",
"createdAt": "2023-09-11T18:44:40.000Z",
"mergedAt": "2023-10-18T23:36:08.000Z",
"mergeCommitSha": "fcb21b478f78297850894c71abee35ab98042823",
"author": "Yopai",
"repoName": "conventional-commits/conventionalcommits.org",
"labels": ["--rcba-merged"],
"milestone": "",
"body": "I've reviewed the whole text to make it more natural for a native french speaking.",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 550,
"title": "Add/update tool/project links",
"htmlURL": "https://github.com/conventional-commits/conventionalcommits.org/pull/550",
"baseBranch": "master",
"branch": "patch-1",
"createdAt": "2023-10-19T10:31:50.000Z",
"mergedAt": "2023-10-19T10:44:22.000Z",
"mergeCommitSha": "79d1a4cbdbf9f04eebc531c0e76e7fbb8ebb4b95",
"author": "postspectacular",
"repoName": "conventional-commits/conventionalcommits.org",
"labels": ["--rcba-merged"],
"milestone": "",
"body": "- add link to thi.ng/monopub release tool\r\n- update thi.ng/umbrella project description",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 512,
"title": "fix(ja): fix typo",
"htmlURL": "https://github.com/conventional-commits/conventionalcommits.org/pull/512",
"baseBranch": "master",
"branch": "patch-1",
"createdAt": "2023-03-14T15:13:19.000Z",
"mergedAt": "2023-10-19T10:45:42.000Z",
"mergeCommitSha": "64ae03aacea2a3cf5271f4217d266db10f2c3043",
"author": "moritasoshi",
"repoName": "conventional-commits/conventionalcommits.org",
"labels": ["--rcba-merged"],
"milestone": "",
"body": "Fixed `意味的にを` -> `意味的に`.\r\n\r\n`意味的にを` is incorrect Japanese.",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 530,
"title": "docs: add link to git-changelog-command-line docker image",
"htmlURL": "https://github.com/conventional-commits/conventionalcommits.org/pull/530",
"baseBranch": "master",
"branch": "feature/git-changelog-command-line-docker",
"createdAt": "2023-06-11T07:32:14.000Z",
"mergedAt": "2023-10-19T10:47:20.000Z",
"mergeCommitSha": "158a7b14ef1f8c24b3e9a7cee97bd0e2c0bd6397",
"author": "tomasbjerre",
"repoName": "conventional-commits/conventionalcommits.org",
"labels": ["--rcba-merged"],
"milestone": "",
"body": "",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 527,
"title": "docs: Add descriptions for commit types",
"htmlURL": "https://github.com/conventional-commits/conventionalcommits.org/pull/527",
"baseBranch": "master",
"branch": "docs/zh-hans",
"createdAt": "2023-05-19T09:56:11.000Z",
"mergedAt": "2023-10-19T10:48:46.000Z",
"mergeCommitSha": "551cfd47a533f6222d0c9c06af096d4076b48bc9",
"author": "HExris",
"repoName": "conventional-commits/conventionalcommits.org",
"labels": ["--rcba-merged"],
"milestone": "",
"body": "",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 520,
"title": "fix(zh-hant): Distinguish translations of 'Release/Publish'",
"htmlURL": "https://github.com/conventional-commits/conventionalcommits.org/pull/520",
"baseBranch": "master",
"branch": "fix-release-publish",
"createdAt": "2023-04-17T17:48:40.000Z",
"mergedAt": "2023-10-19T10:49:51.000Z",
"mergeCommitSha": "5b935ded2e6b2cbdb3cf24f327b49ed23e31858d",
"author": "hwhsu1231",
"repoName": "conventional-commits/conventionalcommits.org",
"labels": ["--rcba-merged"],
"milestone": "",
"body": "Before:\r\n\r\n* Release: 發布, 版本, 版本釋出\r\n* Publish: 發布\r\n\r\nAfter:\r\n\r\n* Release: 發行(版)\r\n* Publish: 發布",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 551,
"title": "\"feat(lang): add Bengali translation\" ",
"htmlURL": "https://github.com/conventional-commits/conventionalcommits.org/pull/551",
"baseBranch": "master",
"branch": "master",
"createdAt": "2023-10-30T22:10:26.000Z",
"mergedAt": "2023-11-05T13:42:26.000Z",
"mergeCommitSha": "69f9447d5648efb3bb028bc27a2276fcacb9a20d",
"author": "forhadakhan",
"repoName": "conventional-commits/conventionalcommits.org",
"labels": ["--rcba-merged"],
"milestone": "",
"body": "This will add the Bengali translation.",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 558,
"title": "feat(lang): add uzbek translation",
"htmlURL": "https://github.com/conventional-commits/conventionalcommits.org/pull/558",
"baseBranch": "master",
"branch": "feature/add-uzbek-lang",
"createdAt": "2024-01-02T12:32:12.000Z",
"mergedAt": "2024-01-22T07:55:14.000Z",
"mergeCommitSha": "f777146b5d331c9ee33b0028e861df14e3992fe9",
"author": "softXengineer",
"repoName": "conventional-commits/conventionalcommits.org",
"labels": ["--rcba-merged"],
"milestone": "",
"body": "",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 567,
"title": "fix(ko): fix translation typo for message",
"htmlURL": "https://github.com/conventional-commits/conventionalcommits.org/pull/567",
"baseBranch": "master",
"branch": "master",
"createdAt": "2024-01-29T12:05:13.000Z",
"mergedAt": "2024-01-29T12:49:09.000Z",
"mergeCommitSha": "325b74fbc44bf34d9fa645951d076a450b4e26be",
"author": "Igoc",
"repoName": "conventional-commits/conventionalcommits.org",
"labels": ["--rcba-merged"],
"milestone": "",
"body": "Fixed `메세지` → `메시지`.\r\n\r\nReference: [국립국어원 표준국어대사전](https://stdict.korean.go.kr/search/searchView.do?word_no=113651&searchKeywordTo=3)",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 0,
"title": "fix: Fix grammar and consistency in french translation (#546)",
"htmlURL": "",
"baseBranch": "",
"createdAt": "2023-10-18T23:36:07.000Z",
"mergedAt": "2023-10-18T23:36:07.000Z",
"mergeCommitSha": "fcb21b478f78297850894c71abee35ab98042823",
"author": "Yopai",
"repoName": "",
"labels": [],
"milestone": "",
"body": "fix: Fix grammar and consistency in french translation (#546)",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 0,
"title": "doc: new thi.ng links and descriptions",
"htmlURL": "",
"baseBranch": "",
"createdAt": "2023-10-19T10:44:22.000Z",
"mergedAt": "2023-10-19T10:44:22.000Z",
"mergeCommitSha": "79d1a4cbdbf9f04eebc531c0e76e7fbb8ebb4b95",
"author": "postspectacular",
"repoName": "",
"labels": [],
"milestone": "",
"body": "doc: new thi.ng links and descriptions",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 0,
"title": "fix(ja): fix typo",
"htmlURL": "",
"baseBranch": "",
"createdAt": "2023-10-19T10:45:42.000Z",
"mergedAt": "2023-10-19T10:45:42.000Z",
"mergeCommitSha": "64ae03aacea2a3cf5271f4217d266db10f2c3043",
"author": "moritasoshi",
"repoName": "",
"labels": [],
"milestone": "",
"body": "fix(ja): fix typo",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 0,
"title": "docs: add link to git-changelog-command-line docker image",
"htmlURL": "",
"baseBranch": "",
"createdAt": "2023-10-19T10:47:20.000Z",
"mergedAt": "2023-10-19T10:47:20.000Z",
"mergeCommitSha": "158a7b14ef1f8c24b3e9a7cee97bd0e2c0bd6397",
"author": "tomasbjerre",
"repoName": "",
"labels": [],
"milestone": "",
"body": "docs: add link to git-changelog-command-line docker image",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 0,
"title": "docs: Add descriptions for commit types",
"htmlURL": "",
"baseBranch": "",
"createdAt": "2023-10-19T10:48:46.000Z",
"mergedAt": "2023-10-19T10:48:46.000Z",
"mergeCommitSha": "551cfd47a533f6222d0c9c06af096d4076b48bc9",
"author": "HExris",
"repoName": "",
"labels": [],
"milestone": "",
"body": "docs: Add descriptions for commit types",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 0,
"title": "fix(zh-hant): Distinguish translations of 'Release/Publish'",
"htmlURL": "",
"baseBranch": "",
"createdAt": "2023-10-19T10:49:51.000Z",
"mergedAt": "2023-10-19T10:49:51.000Z",
"mergeCommitSha": "5b935ded2e6b2cbdb3cf24f327b49ed23e31858d",
"author": "hwhsu1231",
"repoName": "",
"labels": [],
"milestone": "",
"body": "fix(zh-hant): Distinguish translations of 'Release/Publish'",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 0,
"title": "feat(lang): add Bengali",
"htmlURL": "",
"baseBranch": "",
"createdAt": "2023-11-05T13:42:26.000Z",
"mergedAt": "2023-11-05T13:42:26.000Z",
"mergeCommitSha": "69f9447d5648efb3bb028bc27a2276fcacb9a20d",
"author": "forhadakhan",
"repoName": "",
"labels": [],
"milestone": "",
"body": "feat(lang): add Bengali",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 0,
"title": "feat(lang): add uzbek translation (#558)",
"htmlURL": "",
"baseBranch": "",
"createdAt": "2024-01-22T07:55:14.000Z",
"mergedAt": "2024-01-22T07:55:14.000Z",
"mergeCommitSha": "f777146b5d331c9ee33b0028e861df14e3992fe9",
"author": "softXengineer",
"repoName": "",
"labels": [],
"milestone": "",
"body": "feat(lang): add uzbek translation (#558)",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
},
{
"number": 0,
"title": "fix(ko): fix translation typo for message (#567)",
"htmlURL": "",
"baseBranch": "",
"createdAt": "2024-01-29T12:49:09.000Z",
"mergedAt": "2024-01-29T12:49:09.000Z",
"mergeCommitSha": "325b74fbc44bf34d9fa645951d076a450b4e26be",
"author": "Igoc",
"repoName": "",
"labels": [],
"milestone": "",
"body": "fix(ko): fix translation typo for message (#567)",
"assignees": [],
"requestedReviewers": [],
"approvedReviewers": [],
"status": "merged"
}
],
"diffInfo": {
"changedFiles": 11,
"additions": 579,
"deletions": 96,
"changes": 675,
"commits": 9,
"commitInfo": [
{
"sha": "fcb21b478f78297850894c71abee35ab98042823",
"summary": "fix: Fix grammar and consistency in french translation (#546)",
"message": "fix: Fix grammar and consistency in french translation (#546)",
"author": "Yopai",
"authorDate": "2023-10-18T23:36:07.000Z",
"committer": "web-flow",
"commitDate": "2023-10-18T23:36:07.000Z"
},
{
"sha": "79d1a4cbdbf9f04eebc531c0e76e7fbb8ebb4b95",
"summary": "doc: new thi.ng links and descriptions",
"message": "doc: new thi.ng links and descriptions",
"author": "postspectacular",
"authorDate": "2023-10-19T10:44:22.000Z",
"committer": "web-flow",
"commitDate": "2023-10-19T10:44:22.000Z"
},
{
"sha": "64ae03aacea2a3cf5271f4217d266db10f2c3043",
"summary": "fix(ja): fix typo",
"message": "fix(ja): fix typo",
"author": "moritasoshi",
"authorDate": "2023-10-19T10:45:42.000Z",
"committer": "web-flow",
"commitDate": "2023-10-19T10:45:42.000Z"
},
{
"sha": "158a7b14ef1f8c24b3e9a7cee97bd0e2c0bd6397",
"summary": "docs: add link to git-changelog-command-line docker image",
"message": "docs: add link to git-changelog-command-line docker image",
"author": "tomasbjerre",
"authorDate": "2023-10-19T10:47:20.000Z",
"committer": "web-flow",
"commitDate": "2023-10-19T10:47:20.000Z"
},
{
"sha": "551cfd47a533f6222d0c9c06af096d4076b48bc9",
"summary": "docs: Add descriptions for commit types",
"message": "docs: Add descriptions for commit types",
"author": "HExris",
"authorDate": "2023-10-19T10:48:46.000Z",
"committer": "web-flow",
"commitDate": "2023-10-19T10:48:46.000Z"
},
{
"sha": "5b935ded2e6b2cbdb3cf24f327b49ed23e31858d",
"summary": "fix(zh-hant): Distinguish translations of 'Release/Publish'",
"message": "fix(zh-hant): Distinguish translations of 'Release/Publish'",
"author": "hwhsu1231",
"authorDate": "2023-10-19T10:49:51.000Z",
"committer": "web-flow",
"commitDate": "2023-10-19T10:49:51.000Z"
},
{
"sha": "69f9447d5648efb3bb028bc27a2276fcacb9a20d",
"summary": "feat(lang): add Bengali",
"message": "feat(lang): add Bengali",
"author": "forhadakhan",
"authorDate": "2023-11-05T13:42:26.000Z",
"committer": "web-flow",
"commitDate": "2023-11-05T13:42:26.000Z"
},
{
"sha": "f777146b5d331c9ee33b0028e861df14e3992fe9",
"summary": "feat(lang): add uzbek translation (#558)",
"message": "feat(lang): add uzbek translation (#558)",
"author": "softXengineer",
"authorDate": "2024-01-22T07:55:14.000Z",
"committer": "web-flow",
"commitDate": "2024-01-22T07:55:14.000Z"
},
{
"sha": "325b74fbc44bf34d9fa645951d076a450b4e26be",
"summary": "fix(ko): fix translation typo for message (#567)",
"message": "fix(ko): fix translation typo for message (#567)",
"author": "Igoc",
"authorDate": "2024-01-29T12:49:09.000Z",
"committer": "web-flow",
"commitDate": "2024-01-29T12:49:09.000Z"
}
]
},
"options": {
"owner": "conventional-commits",
"repo": "conventionalcommits.org",
"fromTag": {"name": "1e1c8e11e6cb7e555e5e53f8eed5ba5fc5029993"},
"toTag": {"name": "325b74fbc44bf34d9fa645951d076a450b4e26be"},
"includeOpen": false,
"failOnError": false,
"fetchViaCommits": false,
"fetchReviewers": false,
"fetchReleaseInformation": false,
"fetchReviews": false,
"mode": "HYBRID",
"configuration": {
"max_tags_to_fetch": 200,
"max_pull_requests": 200,
"max_back_track_time_days": 365,
"exclude_merge_branches": [],
"sort": {"order": "ASC", "on_property": "mergedAt"},
"template": "#{{CHANGELOG}}",
"pr_template": "- #{{TITLE}}",
"empty_template": "- no changes",
"categories": [
{"title": "## 🚀 Big features", "labels": ["feature", "feat"], "mode": "PR"},
{"title": "## 🚀 Small features", "labels": ["feature", "feat"], "mode": "COMMIT"},
{"title": "## 🐛 Fixes", "labels": ["fix", "bug"]},
{"title": "## 🧪 Tests", "labels": ["test"]},
{"title": "## 📦 Other", "labels": []}
],
"ignore_labels": ["ignore"],
"label_extractor": [
{
"pattern": "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)",
"target": "$1",
"on_property": "title"
}
],
"transformers": [],
"tag_resolver": {"method": "semver"},
"base_branches": [],
"custom_placeholders": [],
"trim_values": false
}
}
}
Generated Vendored
+4043 -2688
View File
File diff suppressed because it is too large Load Diff
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
Generated Vendored
+27
View File
@@ -575,6 +575,33 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
fast-content-type-parse
MIT
MIT License
Copyright (c) 2023 The Fastify Team
The Fastify team members are listed at https://github.com/fastify/fastify#team
and in the README file.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
gitea-js
MIT
MIT License
Generated Vendored
-1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -19,7 +19,7 @@ export default [{
ignores: ["**/dist/", "**/lib/", "**/node_modules/"]
}, ...compat.extends("plugin:github/recommended"), {
files: ["src/**.ts", "__tests__/**.ts"],
files: ["**/*.ts", "__tests__/**.ts"],
plugins: {
jest,
+7 -7
View File
@@ -1,12 +1,12 @@
// jest.config.js
import { createJsWithTsEsmPreset } from "ts-jest";
import { createDefaultEsmPreset } from "ts-jest";
export default {
clearMocks: true,
testEnvironment: "node",
testMatch: ["**/*.test.ts"],
testRunner: "jest-circus/runner",
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"(.+)\\.js": "$1",
"(.+)\\.js": "$1"
},
...createJsWithTsEsmPreset(),
}
...createDefaultEsmPreset()
};
+979 -1113
View File
File diff suppressed because it is too large Load Diff
+18 -18
View File
@@ -1,6 +1,6 @@
{
"name": "release-changelog-builder-action",
"version": "v5.1.0",
"version": "v5.2.0",
"private": true,
"description": "A GitHub action that builds your release notes / changelog fast, easy and exactly the way you want.",
"main": "lib/main.js",
@@ -12,10 +12,10 @@
"format-fix": "eslint --fix src/**.ts",
"lint": "eslint src/**/*.ts",
"package": "ncc build --source-map --license licenses.txt",
"test": "jest",
"test-github": "jest __tests__/*.test.ts",
"test-gitea": "jest __tests__/gitea/*.test.ts",
"test-demo": "jest __tests__/demo/*.test.ts",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"test-github": "NODE_OPTIONS=--experimental-vm-modules jest __tests__/*.test.ts",
"test-gitea": "NODE_OPTIONS=--experimental-vm-modules jest __tests__/gitea/*.test.ts",
"test-demo": "NODE_OPTIONS=--experimental-vm-modules jest __tests__/demo/*.test.ts",
"all": "npm run build && npm run format && npm run lint && npm run package && npm run test-github"
},
"repository": {
@@ -40,34 +40,34 @@
"@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1",
"@actions/github": "^6.0.0",
"@octokit/rest": "^20.1.1",
"@octokit/rest": "^21.1.1",
"gitea-js": "^1.23.0",
"globals": "^15.14.0",
"globals": "^15.15.0",
"https-proxy-agent": "^7.0.6",
"moment": "^2.30.1",
"semver": "^7.6.3"
"semver": "^7.7.1"
},
"devDependencies": {
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.20.0",
"@types/jest": "^29.5.14",
"@types/node": "^22.10.10",
"@types/node": "^22.13.4",
"@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^8.21.0",
"@typescript-eslint/parser": "^8.21.0",
"@typescript-eslint/eslint-plugin": "^8.24.1",
"@typescript-eslint/parser": "^8.24.1",
"@vercel/ncc": "^0.38.3",
"eslint": "^9.19.0",
"eslint-plugin-github": "^5.1.5",
"eslint": "^9.20.1",
"eslint-import-resolver-typescript": "^3.8.1",
"eslint-plugin-github": "^5.1.8",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.11.0",
"eslint-plugin-prettier": "^5.2.3",
"eslint-import-resolver-typescript": "^3.7.0",
"jest": "^29.7.0",
"jest-circus": "^29.7.0",
"js-yaml": "^4.1.0",
"prettier": "3.4.2",
"prettier": "3.5.1",
"ts-jest": "^29.2.5",
"typescript": "^5.7.3",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.19.0"
"typescript": "^5.7.3"
},
"overrides": {
"glob": "11.0.1"
+3 -1
View File
@@ -3,6 +3,7 @@ import {Extractor, PullConfiguration, Regex, Rule} from './pr-collector/types.js
export interface Configuration extends PullConfiguration {
template: string
pr_template: string
commit_template: string // (COMMIT and HYBRID mode only for PRs converted to commits)
empty_template: string
categories: Category[]
ignore_labels: string[]
@@ -25,6 +26,7 @@ export interface Category {
empty_content?: string // if the category has no matching PRs, this content will be used. If not set, the category will be skipped in the changelog.
categories?: Category[] // allows for nested categories, items matched for a child category won't show up in the parent
consume?: boolean // defines if the matched PR will be consumed by this category. Consumed PRs won't show up in any category *after*
mode?: 'HYBRID' | 'COMMIT' | 'PR' // defines if this category applies to PRs, commits or both
entries?: string[] // array of single changelog entries, used to construct the changelog. (this is filled during the build)
}
@@ -70,6 +72,7 @@ export const DefaultConfiguration: Configuration = {
},
template: '#{{CHANGELOG}}', // the global template to host the changelog
pr_template: '- #{{TITLE}}\n - PR: ##{{NUMBER}}', // the per PR template to pick
commit_template: '- #{{TITLE}}', // the per PR template to pick for commit based mode
empty_template: '- no changes', // the template to use if no pull requests are found
categories: [
{
@@ -106,7 +109,6 @@ export const DefaultConfiguration: Configuration = {
export const DefaultCommitConfiguration: Configuration = {
...DefaultConfiguration,
pr_template: '- #{{TITLE}}', // the per PR template to pick
categories: [
{
title: '## 🚀 Features',
+48 -20
View File
@@ -194,6 +194,7 @@ export class GithubRepository extends BaseRepository {
auth: `token ${this.token}`,
baseUrl: this.url
})
if (this.proxy) {
const agent = new HttpsProxyAgent(this.proxy)
this.octokit.hook.before('request', options => {
@@ -206,32 +207,59 @@ export class GithubRepository extends BaseRepository {
}
async getTags(owner: string, repo: string, maxTagsToFetch: number): Promise<TagInfo[]> {
const pageSize = maxTagsToFetch > 100 ? 100 : maxTagsToFetch // 100 max page size in graphql
const tagsInfo: TagInfo[] = []
const options = this.octokit.repos.listTags.endpoint.merge({
owner,
repo,
direction: 'desc',
per_page: 100
})
for await (const response of this.octokit.paginate.iterator(options)) {
type TagsListData = RestEndpointMethodTypes['repos']['listTags']['response']['data']
const tags: TagsListData = response.data as TagsListData
for (const tag of tags) {
tagsInfo.push({
name: tag.name,
commit: tag.commit.sha
})
let hasNextPage = true
let cursor: string | null = null
while (hasNextPage && tagsInfo.length < maxTagsToFetch) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const result: any = await this.octokit.graphql(`
{
repository(owner: "${owner}", name: "${repo}") {
refs(refPrefix: "refs/tags/", first: ${pageSize}, after: ${cursor ? `"${cursor}"` : 'null'}, orderBy: {field: TAG_COMMIT_DATE, direction: DESC}) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
name
target {
oid
... on Tag {
message
commitUrl
tagger {
name
email
date
}
}
}
}
}
}
}
}
`)
// for performance only fetch newest maxTagsToFetch tags!!
if (tagsInfo.length >= maxTagsToFetch) {
break
}
const refs = result.repository.refs
hasNextPage = refs.pageInfo.hasNextPage && tagsInfo.length < maxTagsToFetch
cursor = refs.pageInfo.endCursor
// eslint-disable-next-line github/array-foreach, @typescript-eslint/no-explicit-any
refs.edges.forEach((edge: any) => {
if (tagsInfo.length < maxTagsToFetch) {
tagsInfo.push({
name: edge.node.name,
commit: edge.node.target.oid
})
}
})
}
core.info(`Found ${tagsInfo.length} (fetching max: ${maxTagsToFetch}) tags from the GitHub API for ${owner}/${repo}`)
core.info(`Retrieved ${tagsInfo.length} (fetching max: ${maxTagsToFetch}) tags from the GitHub API for ${owner}/${repo}`)
return tagsInfo
}
+61 -6
View File
@@ -127,22 +127,47 @@ export function buildChangelog(diffInfo: DiffInfo, origPrs: PullRequestInfo[], o
core.info(`️ Using ${validatedTransformers.length} transformers to rewrite content`)
const includePrs = options.mode === 'PR' || options.mode === 'HYBRID'
const includeCommits = options.mode === 'COMMIT' || options.mode === 'HYBRID'
// convert PRs to their text representation
const realPrs = includePrs ? prs.filter(x => x.number !== 0) : []
const commitPrs = includeCommits ? prs.filter(x => x.number === 0) : []
if (validatedTransformers.length > 0) {
for (const pr of prs) {
const prAsObject = pr as unknown as Record<string, unknown>
transformObject(prAsObject, validatedTransformers)
}
core.info(`✒️ Transformed ${prs.length} pull requests`)
if (includePrs) {
core.info(`✒️ Transformed ${realPrs.length} pull requests`)
}
if (includeCommits) {
core.info(`✒️ Transformed ${commitPrs.length} commits`)
}
}
const prInfoMap = buildInfoMapAndFillPlaceholderContext(
prs,
realPrs,
config.pr_template,
groupedPlaceholders,
customPlaceholdersTemplateContext,
config
)
const commitInfoMap = buildInfoMapAndFillPlaceholderContext(
commitPrs,
config.commit_template,
groupedPlaceholders,
customPlaceholdersTemplateContext,
config
)
// If the mode is not HYBRID, the map will contain only one or the other map
const combinedInfoMap = mergeMaps(prInfoMap, commitInfoMap)
// bring PRs into the order of categories
const categories = config.categories
const flatCategories = flatten(config.categories)
@@ -154,7 +179,7 @@ export function buildChangelog(diffInfo: DiffInfo, origPrs: PullRequestInfo[], o
}
}
const prStrings = buildPrStringsAndFillCategoryEntries(prInfoMap, config.ignore_labels, categories, flatCategories)
const prStrings = buildPrStringsAndFillCategoryEntries(combinedInfoMap, config.ignore_labels, categories, flatCategories)
core.info(`️ Ordered all pull requests into ${categories.length} categories`)
// serialize and provide the categorized content as json
@@ -272,7 +297,8 @@ function buildPrStringsAndFillCategoryEntries(
}
let matchedOnce = false // in case we matched once at least, the PR can't be uncategorized
for (const category of categories) {
const filteredCategories = filterCategoriesByPrType(categories, pr)
for (const category of filteredCategories) {
const [matched, consumed] = recursiveCategorizePr(category, pr, body)
if (consumed) {
continue prLoop
@@ -282,7 +308,8 @@ function buildPrStringsAndFillCategoryEntries(
if (!matchedOnce) {
// we allow to have pull requests included in an "uncategorized" category
for (const category of flatCategories) {
const filteredFlatCategories = filterCategoriesByPrType(flatCategories, pr)
for (const category of filteredFlatCategories) {
category.entries = category.entries || []
if ((category.labels === undefined || category.labels.length === 0) && category.rules === undefined) {
// check if any exclude label matches for the "uncategorized" category
@@ -546,7 +573,15 @@ export function renderEmptyChangelogTemplate(template: string, options: ReleaseN
const releaseNotesTemplateContext = buildCoreReleaseNotesTemplateContext(options)
return renderTemplateAndFillPlaceholderContext(template, releaseNotesTemplateContext, placeholders, undefined, options.configuration)
const renderedEmptyChangelogTemplate = renderTemplateAndFillPlaceholderContext(
template,
releaseNotesTemplateContext,
placeholders,
undefined,
options.configuration
)
return renderedEmptyChangelogTemplate
}
function buildCoreReleaseNotesTemplateContext(options: ReleaseNotesOptions): TemplateContext {
@@ -867,3 +902,23 @@ function hasChildWithEntries(category: Category): boolean {
}
return hasEntries
}
/**
* Filters the provided categories based on the type of pull request information.
*
* @param {Category[]} categories - The list of categories to filter.
* @param {PullRequestInfo} prInfo - The pull request information used to determine the type of PR.
* @returns {Category[]} The filtered list of categories:
* - If 'prInfo' represents a real pull request (has a number other than 0), it excludes categories with mode 'COMMIT'.
* - If 'prInfo' represents a commit (has number 0), it excludes categories with mode 'PR'.
* - Defaults to keeping categories with mode 'HYBRID' in either case.
*/
function filterCategoriesByPrType(categories: Category[], prInfo: PullRequestInfo): Category[] {
const isRealPr = prInfo.number !== 0
if (isRealPr) {
return categories.filter(category => (category.mode || 'HYBRID') !== 'COMMIT')
} else {
return categories.filter(category => (category.mode || 'HYBRID') !== 'PR')
}
}
+25 -1
View File
@@ -107,6 +107,16 @@ export function checkExportedData(exportCache: boolean, cacheInput: string | nul
options.toTag.date = moment(options.toTag.date)
}
// Handle backwards compatibility for addition of `commit_template` in COMMIT and HYBRID mode
// If there is no provided commit_template, fallback to the provided pr_template,
// and if that is not provided either, fallback to the default commit_template
const {mode, configuration} = options
const prTemplate = configuration?.pr_template
const commitTemplate = configuration?.commit_template
if ((mode === 'COMMIT' || mode === 'HYBRID') && !commitTemplate) {
options.configuration.commit_template = prTemplate || DefaultConfiguration.commit_template
}
return {
diffInfo,
mergedPullRequests,
@@ -198,6 +208,19 @@ export function mergeConfiguration(jc?: Configuration, fc?: Configuration, mode?
def = DefaultConfiguration
}
// Handle backwards compatibility for addition of `commit_template` in COMMIT and HYBRID mode
// If there is no provided commit_template, fallback to the provided pr_template,
// and if that is not provided either, fallback to the default commit_template
const prTemplate = jc?.pr_template || fc?.pr_template
let commitTemplate = jc?.commit_template || fc?.commit_template
if ((mode === 'COMMIT' || mode === 'HYBRID') && !commitTemplate) {
if (prTemplate) {
commitTemplate = prTemplate
} else {
commitTemplate = def.commit_template
}
}
return {
max_tags_to_fetch: jc?.max_tags_to_fetch || fc?.max_tags_to_fetch || def.max_tags_to_fetch,
max_pull_requests: jc?.max_pull_requests || fc?.max_pull_requests || def.max_pull_requests,
@@ -205,7 +228,8 @@ export function mergeConfiguration(jc?: Configuration, fc?: Configuration, mode?
exclude_merge_branches: jc?.exclude_merge_branches || fc?.exclude_merge_branches || def.exclude_merge_branches,
sort: jc?.sort || fc?.sort || def.sort,
template: jc?.template || fc?.template || def.template,
pr_template: jc?.pr_template || fc?.pr_template || def.pr_template,
pr_template: prTemplate || def.pr_template,
commit_template: commitTemplate || def.commit_template,
empty_template: jc?.empty_template || fc?.empty_template || def.empty_template,
categories: jc?.categories || fc?.categories || def.categories,
ignore_labels: jc?.ignore_labels || fc?.ignore_labels || def.ignore_labels,