Merge pull request #1312 from mikepenz/feature/adjust_mode_configuration

Refactor mode configuration | Add support for `HYBRID` | Add new `CommitMode` focused default config
This commit is contained in:
Mike Penz
2024-03-02 21:28:26 +01:00
committed by GitHub
20 changed files with 474 additions and 235 deletions
+2 -6
View File
@@ -168,11 +168,7 @@ jobs:
],
"label_extractor": [
{
"pattern": "^(build|ci|chore|doc|docs|wiki|remove|deprecate|security|dependency|package|feat|feature|fix|bug|perf|optimize|refactor|revert|style|test):(.*)",
"target": "$1"
},
{
"pattern": "^(build|ci|chore|doc|docs|wiki|remove|deprecate|security|dependency|package|feat|feature|fix|bug|perf|optimize|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?:(.*)",
"pattern": "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)",
"target": "$1"
}
],
@@ -776,7 +772,7 @@ it('Test custom changelog builder', async () => {
false, // enable to fetch reviewers
false, // enable to fetch release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // set the mode to use [PR, COMMIT, HYBRID]
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -38,7 +38,7 @@ it('[Gitea] Verify reviewers who approved are fetched and also release informati
true, // enable to fetch reviewers
true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -78,7 +78,7 @@ it('[Gitea] Should match generated changelog (unspecified fromTag)', async () =>
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -115,7 +115,7 @@ it('[Gitea] Should match generated changelog (unspecified tags)', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -151,7 +151,7 @@ it('[Gitea] Should use empty placeholder', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -202,7 +202,7 @@ it('[Gitea] Should fill empty placeholders', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -310,7 +310,7 @@ it('[Gitea] Should fill `template` placeholders', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -419,7 +419,7 @@ it('[Gitea] Should fill `template` placeholders, ignore', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -484,7 +484,7 @@ it('[Gitea] Uncategorized category', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -558,7 +558,7 @@ it('[Gitea] Verify commit based changelog', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
true, // enable commitMode
'COMMIT', // enable commitMode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -635,7 +635,7 @@ it('[Gitea] Verify commit based changelog', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
true, // enable commitMode
'COMMIT', // enable commitMode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -673,7 +673,7 @@ it('[Gitea] Verify default inclusion of open PRs', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -714,7 +714,7 @@ it('[Gitea] Verify custom categorisation of open PRs', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -746,7 +746,7 @@ it('[Gitea] Fetch release information', async () => {
false, // enable to fetch reviewers
true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -780,7 +780,7 @@ it('[Gitea] Fetch release information for non existing tag / release', async ()
false, // enable to fetch reviewers
true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -1,8 +1,9 @@
import {checkExportedData, mergeConfiguration, resolveConfiguration} from '../../src/utils'
import {buildChangelog} from '../../src/transform'
import {pullData} from '../../src/pr-collector/prCollector'
import {Options, pullData} from '../../src/pr-collector/prCollector'
import {GiteaRepository} from '../../src/repositories/GiteaRepository'
import {clear} from '../../src/transform'
import {ReleaseNotesOptions} from '../../src/releaseNotesBuilder'
jest.setTimeout(180000)
clear()
@@ -47,17 +48,17 @@ it('[Gitea] Should have changelog (tags)', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: giteaRepository
}
let data: any
if (enablePullData) {
data = await pullData(giteaRepository, options)
data = await pullData(giteaRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/gitea_rcba_0.5.0-master_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🚀 Features
@@ -85,17 +86,17 @@ it('[Gitea] Should match generated changelog (tags)', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: giteaRepository
}
let data: any
if (enablePullData) {
data = await pullData(giteaRepository, options)
data = await pullData(giteaRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/gitea_rcba_0.5.0-master_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🚀 Features
@@ -124,17 +125,17 @@ it('[Gitea] Should match generated changelog (refs)', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: giteaRepository
}
let data: any
if (enablePullData) {
data = await pullData(giteaRepository, options)
data = await pullData(giteaRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/gitea_rcba_3e49adf-894a64_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 📦 Uncategorized
@@ -181,17 +182,17 @@ it('[Gitea] Should match generated changelog and replace all occurrences (refs)'
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: giteaRepository
}
let data: any
if (enablePullData) {
data = await pullData(giteaRepository, options)
data = await pullData(giteaRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/gitea_rcba_3e49adf-894a64_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 📦 Uncategorized
@@ -243,17 +244,17 @@ it('[Gitea] Should match ordered ASC', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: giteaRepository
}
let data: any
if (enablePullData) {
data = await pullData(giteaRepository, options)
data = await pullData(giteaRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/gitea_rcba_0.1.0-master_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🚀 Features
@@ -300,17 +301,17 @@ it('[Gitea] Should match ordered DESC', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: giteaRepository
}
let data: any
if (enablePullData) {
data = await pullData(giteaRepository, options)
data = await pullData(giteaRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/gitea_rcba_0.1.0-master_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🚀 Features
+14 -14
View File
@@ -25,7 +25,7 @@ it('[Github] Should match generated changelog (unspecified fromTag)', async () =
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -59,7 +59,7 @@ it('[Github] Should match generated changelog (unspecified tags)', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -88,7 +88,7 @@ it('[Github] Should use empty placeholder', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
'caches/rcba_0.0.2-0.0.3_cache.json', // path to the cache
@@ -117,7 +117,7 @@ it('[Github] Should fill empty placeholders', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
'caches/rcba_0.0.2-0.0.3_cache.json', // path to the cache
@@ -148,7 +148,7 @@ it('[Github] Should fill `template` placeholders', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
'caches/rcba_0.0.1-0.0.3_cache.json', // path to the cache
@@ -180,7 +180,7 @@ it('[Github] Should fill `template` placeholders, ignore', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
'caches/rcba_0.9.1-0.9.5_cache.json', // path to the cache
@@ -211,7 +211,7 @@ it('[Github] Uncategorized category', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
'caches/rcba_0.9.1-0.9.5_cache.json', // path to the cache
@@ -242,7 +242,7 @@ it('[Github] Verify commit based changelog', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
true, // enable commitMode
'COMMIT', // enable commitMode
false, // enable exportCache
false, // enable exportOnly
'caches/rcba_0.0.1-0.0.3_commit_cache.json', // path to the cache
@@ -273,7 +273,7 @@ it('[Github] Verify commit based changelog, with emoji categorisation', async ()
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
true, // enable commitMode
'COMMIT', // enable commitMode
false, // enable exportCache
false, // enable exportOnly
'caches/stackzy_bd3242-17a9e4_cache.json', // path to the cache
@@ -304,7 +304,7 @@ it('[Github] Verify default inclusion of open PRs', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -335,7 +335,7 @@ it('[Github] Verify custom categorisation of open PRs', async () => {
false, // enable to fetch reviewers
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -366,7 +366,7 @@ it('[Github] Verify reviewers who approved are fetched and also release informat
true, // enable to fetch reviewers
true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -398,7 +398,7 @@ it('[Github] Fetch release information', async () => {
false, // enable to fetch reviewers
true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
@@ -428,7 +428,7 @@ it('[Github] Fetch release information for non existing tag / release', async ()
false, // enable to fetch reviewers
true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
'PR', // mode
false, // enable exportCache
false, // enable exportOnly
null, // path to the cache
+106 -31
View File
@@ -1,8 +1,9 @@
import {checkExportedData, mergeConfiguration, resolveConfiguration} from '../src/utils'
import {buildChangelog} from '../src/transform'
import {pullData} from '../src/pr-collector/prCollector'
import {Options, pullData} from '../src/pr-collector/prCollector'
import {GithubRepository} from '../src/repositories/GithubRepository'
import {clear} from '../src/transform'
import {ReleaseNotesOptions} from '../src/releaseNotesBuilder'
jest.setTimeout(180000)
clear()
@@ -26,17 +27,17 @@ it('Should have empty changelog (tags)', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options)
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/rcba_0.0.2-0.0.3_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual('- no changes')
})
@@ -54,17 +55,17 @@ it('Should match generated changelog (tags)', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options)
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/rcba_0.0.1-0.0.3_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🧪 Tests
@@ -88,17 +89,17 @@ it('Should match generated changelog (refs)', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options)
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/rcba_5ec7a2-fa3788_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🧪 Tests
@@ -129,17 +130,17 @@ it('Should match generated changelog and replace all occurrences (refs)', async
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options)
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/rcba_5ec7a2-fa3788_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🧪 Tests
@@ -173,17 +174,17 @@ it('Should match ordered ASC', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options)
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/rcba_0.3.0-0.5.0_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🚀 Features\n\n22\n24\n25\n26\n28\n\n## 🐛 Fixes\n\n23\n\n`)
})
@@ -202,17 +203,17 @@ it('Should match ordered DESC', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options)
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/rcba_0.3.0-0.5.0_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`## 🚀 Features\n\n28\n26\n25\n24\n22\n\n## 🐛 Fixes\n\n23\n\n`)
})
@@ -230,17 +231,17 @@ it('Should match ordered by title ASC', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options)
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/rcba_0.3.0-0.5.0_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(
`## 🚀 Features\n\nEnhanced action logs\nImprove README\nImproved configuration failure handling\nImproved defaults if no configuration is provided\nIntroduce additional placeholders [milestone, labels, assignees, reviewers]\n\n## 🐛 Fixes\n\nImproved handling for non existing tags\n\n`
@@ -260,17 +261,17 @@ it('Should match ordered by title DESC', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options)
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/rcba_0.3.0-0.5.0_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(
`## 🚀 Features\n\nIntroduce additional placeholders [milestone, labels, assignees, reviewers]\nImproved defaults if no configuration is provided\nImproved configuration failure handling\nImprove README\nEnhanced action logs\n\n## 🐛 Fixes\n\nImproved handling for non existing tags\n\n`
@@ -290,17 +291,17 @@ it('Should ignore PRs not merged into develop branch', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options)
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/rcba_1.3.1-1.4.0_base_develop_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`150\n\n`)
})
@@ -318,17 +319,91 @@ it('Should ignore PRs not merged into main branch', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration,
repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options)
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/rcba_1.3.1-1.4.0_base_main_cache.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(`153\n\n`)
})
it('Default configuration with commit mode', async () => {
const configuration = Object.assign({}, mergeConfiguration(undefined, undefined, 'COMMIT'))
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: 'COMMIT',
configuration,
repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/github_conventional-commits-1e1c8e-325b74.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(
`## 🚀 Features\n\n- feat(lang): add Bengali\n- feat(lang): add uzbek translation (#558)\n\n## 🐛 Fixes\n\n- fix: Fix grammar and consistency in french translation (#546)\n- fix(ja): fix typo\n- fix(zh-hant): Distinguish translations of 'Release/Publish'\n- fix(ko): fix translation typo for message (#567)\n\n## 📦 Other\n\n- doc: new thi.ng links and descriptions\n- docs: add link to git-changelog-command-line docker image\n- docs: Add descriptions for commit types\n\n`
)
})
it('Default configuration with commit mode and custom placeholder', async () => {
const configuration = Object.assign({}, mergeConfiguration(undefined, undefined, 'COMMIT'))
configuration.pr_template = '- #{{TITLE_ONLY}}'
configuration.trim_values = true
configuration.custom_placeholders = [
{
name: 'TITLE_ONLY',
source: 'TITLE',
transformer: {
method: 'regexr',
pattern: '(\\w+(\\(.+\\))?: ?)?(.+)',
target: '$3'
}
}
]
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: 'COMMIT',
configuration,
repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
data = await pullData(githubRepository, options as Options)
} else {
data = checkExportedData(false, 'caches/github_conventional-commits-1e1c8e-325b74.json')
}
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options as ReleaseNotesOptions)
console.log(changeLog)
expect(changeLog).toStrictEqual(
`## 🚀 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`
)
})
+2 -2
View File
@@ -457,7 +457,7 @@ it('Commit SHA-1 in commitMode', async () => {
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: true,
mode: 'COMMIT',
configuration: customConfig,
repositoryUtils: repositoryUtils
})
@@ -479,7 +479,7 @@ it('Release Diff', async () => {
fetchReviewers: false,
fetchReleaseInformation: true,
fetchReviews: false,
commitMode: true,
mode: 'COMMIT',
configuration: customConfig,
repositoryUtils: repositoryUtils
})
+3 -1
View File
@@ -81,5 +81,7 @@ it('Match multiple labels exhaustive for category', async () => {
]
const built = buildChangelogTest(customConfig, pullRequestsWithLabels, repositoryUtils)
expect(built).toStrictEqual(`## Core\n\n- Core Ticket\n\n### 🚀 Features\n\n- Core Feature Ticket\n- Mobile & Core Feature Ticket\n\n### 🧪 Bug\n\n- Core Bug Ticket\n- Mobile & Core Bug Ticket\n\n#### 🧪 Bug Bug\n\n- Mobile & Core Bug Bug Ticket\n\n## Mobile\n\n\n### 🚀 Features\n\n- Mobile Feature Ticket\n\n### 🧪 Bug\n\n- Mobile Bug Ticket\n\n`)
expect(built).toStrictEqual(
`## Core\n\n- Core Ticket\n\n### 🚀 Features\n\n- Core Feature Ticket\n- Mobile & Core Feature Ticket\n\n### 🧪 Bug\n\n- Core Bug Ticket\n- Mobile & Core Bug Ticket\n\n#### 🧪 Bug Bug\n\n- Mobile & Core Bug Bug Ticket\n\n## Mobile\n\n\n### 🚀 Features\n\n- Mobile Feature Ticket\n\n### 🧪 Bug\n\n- Mobile Bug Ticket\n\n`
)
})
+1 -1
View File
@@ -16,7 +16,7 @@ export const buildChangelogTest = (config: Configuration, prs: PullRequestInfo[]
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
mode: 'PR',
configuration: config,
repositoryUtils
})
+3 -1
View File
@@ -40,8 +40,10 @@ inputs:
fetchReviews:
description: 'Will enable fetching the reviews (comments) attached to the PR'
default: "false"
mode:
description: 'Defines the mode used to retrieve the information. Available options: [`PR`, `COMMIT`, `HYBRID`]. Defaults to `PR`.'
commitMode:
description: 'Enables a `light` commit based mode. This mode generates changelogs based on the commits. Please note that this is not officially supported, and lacks a lot of features only possible with PRs.'
description: '[Deprecated] Enables the commit based mode. This mode generates changelogs based on the commits. Please note that this lacks a lot of features only possible with PRs.'
default: "false"
outputFile:
description: 'If defined, the changelog will get written to this file. (relative to the checkout dir)'
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Generated Vendored
+126 -46
View File
@@ -7,7 +7,7 @@ require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DefaultConfiguration = void 0;
exports.DefaultCommitConfiguration = exports.DefaultConfiguration = void 0;
exports.DefaultConfiguration = {
max_tags_to_fetch: 200, // the amount of tags to fetch from the github API
max_pull_requests: 200, // the amount of pull requests to process
@@ -53,6 +53,46 @@ exports.DefaultConfiguration = {
custom_placeholders: [],
trim_values: false // defines if values are being trimmed prior to inserting
};
exports.DefaultCommitConfiguration = {
max_tags_to_fetch: exports.DefaultConfiguration.max_tags_to_fetch,
max_pull_requests: exports.DefaultConfiguration.max_pull_requests,
max_back_track_time_days: exports.DefaultConfiguration.max_back_track_time_days,
exclude_merge_branches: exports.DefaultConfiguration.exclude_merge_branches,
sort: exports.DefaultConfiguration.sort,
template: '#{{CHANGELOG}}', // the global template to host the changelog
pr_template: '- #{{TITLE}}', // the per PR template to pick for commit based mode
empty_template: exports.DefaultConfiguration.empty_template,
categories: [
{
title: '## 🚀 Features',
labels: ['feature', 'feat']
},
{
title: '## 🐛 Fixes',
labels: ['fix', 'bug']
},
{
title: '## 🧪 Tests',
labels: ['test']
},
{
title: '## 📦 Other',
labels: []
}
], // the categories to support for the ordering
ignore_labels: exports.DefaultConfiguration.ignore_labels,
label_extractor: [
{
pattern: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)',
target: '$1'
}
],
transformers: exports.DefaultConfiguration.transformers,
tag_resolver: exports.DefaultConfiguration.tag_resolver,
base_branches: exports.DefaultConfiguration.base_branches,
custom_placeholders: exports.DefaultConfiguration.custom_placeholders,
trim_values: exports.DefaultConfiguration.trim_values
};
/***/ }),
@@ -141,8 +181,11 @@ function run() {
if (!configJson && !configFile) {
core.info(`️ No configuration provided. Using Defaults.`);
}
// mode of the action (PR, COMMIT, HYBRID)
const mode = (0, utils_1.resolveMode)(core.getInput('mode'), core.getInput('commitMode') === 'true');
core.info(`️ Running in ${mode} mode.`);
// merge configs, use default values from DefaultConfig on missing definition
const configuration = (0, utils_1.mergeConfiguration)(configJson, configFile);
const configuration = (0, utils_1.mergeConfiguration)(configJson, configFile, mode);
// read in repository inputs
const baseUrl = core.getInput('baseUrl');
const token = core.getInput('token') || process.env.GITHUB_TOKEN || '';
@@ -159,12 +202,11 @@ function run() {
const fetchReviewers = core.getInput('fetchReviewers') === 'true';
const fetchReleaseInformation = core.getInput('fetchReleaseInformation') === 'true';
const fetchReviews = core.getInput('fetchReviews') === 'true';
const commitMode = core.getInput('commitMode') === 'true';
const exportCache = core.getInput('exportCache') === 'true';
const exportOnly = core.getInput('exportOnly') === 'true';
const cache = core.getInput('cache');
const repositoryUtils = new supportedPlatform[platform](token, baseUrl, repositoryPath);
const result = yield new releaseNotesBuilder_1.ReleaseNotesBuilder(baseUrl, repositoryUtils, repositoryPath, owner, repo, fromTag, toTag, includeOpen, failOnError, ignorePreReleases, fetchViaCommits, fetchReviewers, fetchReleaseInformation, fetchReviews, commitMode, exportCache, exportOnly, cache, configuration).build();
const result = yield new releaseNotesBuilder_1.ReleaseNotesBuilder(baseUrl, repositoryUtils, repositoryPath, owner, repo, fromTag, toTag, includeOpen, failOnError, ignorePreReleases, fetchViaCommits, fetchReviewers, fetchReleaseInformation, fetchReviews, mode, exportCache, exportOnly, cache, configuration).build();
core.setOutput('changelog', result);
// write the result in changelog to file if possible
const outputFile = core.getInput('outputFile');
@@ -221,7 +263,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.filterCommits = exports.Commits = exports.DefaultDiffInfo = void 0;
exports.filterCommits = exports.convertCommitsToPrs = exports.Commits = exports.DefaultDiffInfo = void 0;
const core = __importStar(__nccwpck_require__(2186));
const utils_1 = __nccwpck_require__(9613);
exports.DefaultDiffInfo = {
@@ -291,8 +333,14 @@ class Commits {
}
generateCommitPRs(options) {
return __awaiter(this, void 0, void 0, function* () {
const { owner, repo, configuration } = options;
const diffInfo = yield this.getCommitHistory(options);
return convertCommitsToPrs(options, diffInfo);
});
}
}
exports.Commits = Commits;
function convertCommitsToPrs(options, diffInfo) {
const { owner, repo, configuration } = options;
const commits = diffInfo.commitInfo;
if (commits.length === 0) {
return [diffInfo, []];
@@ -320,10 +368,8 @@ class Commits {
};
});
return [diffInfo, prs];
});
}
}
exports.Commits = Commits;
exports.convertCommitsToPrs = convertCommitsToPrs;
/**
* Filters out all commits which match the exclude pattern
*/
@@ -516,7 +562,7 @@ const utils_1 = __nccwpck_require__(9613);
const pullRequests_1 = __nccwpck_require__(4012);
const commits_1 = __nccwpck_require__(234);
class PullRequestCollector {
constructor(baseUrl, repositoryUtils, repositoryPath, owner, repo, fromTag, toTag, includeOpen = false, failOnError, ignorePreReleases, fetchViaCommits = false, fetchReviewers = false, fetchReleaseInformation = false, fetchReviews = false, commitMode = false, configuration) {
constructor(baseUrl, repositoryUtils, repositoryPath, owner, repo, fromTag, toTag, includeOpen = false, failOnError, ignorePreReleases, fetchViaCommits = false, fetchReviewers = false, fetchReleaseInformation = false, fetchReviews = false, mode = 'PR', configuration) {
this.baseUrl = baseUrl;
this.repositoryUtils = repositoryUtils;
this.repositoryPath = repositoryPath;
@@ -531,7 +577,7 @@ class PullRequestCollector {
this.fetchReviewers = fetchReviewers;
this.fetchReleaseInformation = fetchReleaseInformation;
this.fetchReviews = fetchReviews;
this.commitMode = commitMode;
this.mode = mode;
this.configuration = configuration;
}
build() {
@@ -576,7 +622,7 @@ class PullRequestCollector {
fetchReviewers: this.fetchReviewers,
fetchReleaseInformation: this.fetchReleaseInformation,
fetchReviews: this.fetchReviews,
commitMode: this.commitMode,
mode: this.mode,
configuration: this.configuration
});
});
@@ -585,22 +631,28 @@ class PullRequestCollector {
exports.PullRequestCollector = PullRequestCollector;
function pullData(repositoryUtils, options) {
return __awaiter(this, void 0, void 0, function* () {
let mergedPullRequests;
let diffInfo;
let mergedPullRequests = [];
let diffInfo = Object.assign({}, commits_1.DefaultDiffInfo);
const commitsApi = new commits_1.Commits(repositoryUtils);
if (!options.commitMode) {
core.startGroup(`🚀 Load pull requests`);
core.startGroup(`🚀 Load data`);
if (options.mode === 'COMMIT') {
core.info(`🚀 Load commit history (⚠️ Executing experimental commit mode)`);
const [info, prs] = yield commitsApi.generateCommitPRs(options);
mergedPullRequests = mergedPullRequests.concat(prs);
diffInfo = info;
}
else {
// PR mode, HYBRID mode
core.info(`🚀 Load pull requests`);
const pullRequestsApi = new pullRequests_1.PullRequests(repositoryUtils, commitsApi);
const [info, prs] = yield pullRequestsApi.getMergedPullRequests(options);
mergedPullRequests = prs;
diffInfo = info;
if (options.mode === 'HYBRID') {
core.info(`🚀 Converting commits to pull requests`);
const [, fakeCommitPrs] = (0, commits_1.convertCommitsToPrs)(options, info);
mergedPullRequests = mergedPullRequests.concat(fakeCommitPrs);
}
else {
core.startGroup(`🚀 Load commit history`);
core.info(`⚠️ Executing experimental commit mode`);
const [info, prs] = yield commitsApi.generateCommitPRs(options);
mergedPullRequests = prs;
diffInfo = info;
}
core.endGroup();
return {
@@ -1564,7 +1616,7 @@ const transform_1 = __nccwpck_require__(1644);
const prCollector_1 = __nccwpck_require__(2267);
const utils_2 = __nccwpck_require__(9613);
class ReleaseNotesBuilder {
constructor(baseUrl, repositoryUtils, repositoryPath, owner, repo, fromTag, toTag, includeOpen = false, failOnError, ignorePreReleases, fetchViaCommits = false, fetchReviewers = false, fetchReleaseInformation = false, fetchReviews = false, commitMode = false, exportCache = false, exportOnly = false, cache = null, configuration) {
constructor(baseUrl, repositoryUtils, repositoryPath, owner, repo, fromTag, toTag, includeOpen = false, failOnError, ignorePreReleases, fetchViaCommits = false, fetchReviewers = false, fetchReleaseInformation = false, fetchReviews = false, mode = 'PR', exportCache = false, exportOnly = false, cache = null, configuration) {
this.baseUrl = baseUrl;
this.repositoryUtils = repositoryUtils;
this.repositoryPath = repositoryPath;
@@ -1579,7 +1631,7 @@ class ReleaseNotesBuilder {
this.fetchReviewers = fetchReviewers;
this.fetchReleaseInformation = fetchReleaseInformation;
this.fetchReviews = fetchReviews;
this.commitMode = commitMode;
this.mode = mode;
this.exportCache = exportCache;
this.exportOnly = exportOnly;
this.cache = cache;
@@ -1611,7 +1663,7 @@ class ReleaseNotesBuilder {
core.debug(`Resolved 'repo' as ${this.repo}`);
}
core.endGroup();
const prData = yield new prCollector_1.PullRequestCollector(this.baseUrl, this.repositoryUtils, this.repositoryPath, this.owner, this.repo, this.fromTag, this.toTag, this.includeOpen, this.failOnError, this.ignorePreReleases, this.fetchViaCommits, this.fetchReviewers, this.fetchReleaseInformation, this.fetchReviews, this.commitMode, this.configuration).build();
const prData = yield new prCollector_1.PullRequestCollector(this.baseUrl, this.repositoryUtils, this.repositoryPath, this.owner, this.repo, this.fromTag, this.toTag, this.includeOpen, this.failOnError, this.ignorePreReleases, this.fetchViaCommits, this.fetchReviewers, this.fetchReleaseInformation, this.fetchReviews, this.mode, this.configuration).build();
if (prData == null) {
return null;
}
@@ -1625,7 +1677,7 @@ class ReleaseNotesBuilder {
fetchReviewers: this.fetchReviewers,
fetchReleaseInformation: this.fetchReleaseInformation,
fetchReviews: this.fetchReviews,
commitMode: this.commitMode,
mode: this.mode,
configuration: this.configuration,
repositoryUtils: this.repositoryUtils
};
@@ -1673,7 +1725,7 @@ class ReleaseNotesBuilder {
fetchReviewers: this.fetchReviewers || orgOptions.fetchReviewers,
fetchReleaseInformation: this.fetchReleaseInformation || orgOptions.fetchReleaseInformation,
fetchReviews: this.fetchReviews || orgOptions.fetchReviews,
commitMode: this.commitMode || orgOptions.commitMode,
mode: this.mode || orgOptions.mode,
configuration: this.configuration || orgOptions.configuration,
repositoryUtils: this.repositoryUtils || orgOptions.repositoryUtils
};
@@ -3113,7 +3165,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.haveEveryElementsArr = exports.haveEveryElements = exports.haveCommonElementsArr = exports.haveCommonElements = exports.createOrSet = exports.writeOutput = exports.mergeConfiguration = exports.parseConfiguration = exports.resolveConfiguration = exports.checkExportedData = exports.writeCacheData = exports.retrieveRepositoryPath = void 0;
exports.haveEveryElementsArr = exports.haveEveryElements = exports.haveCommonElementsArr = exports.haveCommonElements = exports.createOrSet = exports.writeOutput = exports.mergeConfiguration = exports.parseConfiguration = exports.resolveConfiguration = exports.resolveMode = exports.checkExportedData = exports.writeCacheData = exports.retrieveRepositoryPath = void 0;
const core = __importStar(__nccwpck_require__(2186));
const fs = __importStar(__nccwpck_require__(7147));
const path = __importStar(__nccwpck_require__(1017));
@@ -3226,6 +3278,27 @@ function checkExportedData(exportCache, cacheInput) {
}
}
exports.checkExportedData = checkExportedData;
function resolveMode(mode, commitMode) {
if (commitMode === false || mode === undefined) {
if (commitMode === true) {
return 'COMMIT';
}
else {
return 'PR';
}
}
else {
const upperCaseMode = mode.toUpperCase();
if (upperCaseMode === 'COMMIT') {
return 'COMMIT';
}
else if (upperCaseMode === 'HYBRID') {
return 'HYBRID';
}
}
return 'PR';
}
exports.resolveMode = resolveMode;
/**
* Retrieves the configuration given the file path, if not found it will fallback to the `DefaultConfiguration`
*/
@@ -3286,25 +3359,32 @@ exports.parseConfiguration = parseConfiguration;
/**
* Merges the configurations, will fallback to the DefaultConfiguration value
*/
function mergeConfiguration(jc, fc) {
function mergeConfiguration(jc, fc, mode) {
let def;
if (mode === 'COMMIT') {
def = configuration_1.DefaultCommitConfiguration;
}
else {
def = configuration_1.DefaultConfiguration;
}
return {
max_tags_to_fetch: (jc === null || jc === void 0 ? void 0 : jc.max_tags_to_fetch) || (fc === null || fc === void 0 ? void 0 : fc.max_tags_to_fetch) || configuration_1.DefaultConfiguration.max_tags_to_fetch,
max_pull_requests: (jc === null || jc === void 0 ? void 0 : jc.max_pull_requests) || (fc === null || fc === void 0 ? void 0 : fc.max_pull_requests) || configuration_1.DefaultConfiguration.max_pull_requests,
max_back_track_time_days: (jc === null || jc === void 0 ? void 0 : jc.max_back_track_time_days) || (fc === null || fc === void 0 ? void 0 : fc.max_back_track_time_days) || configuration_1.DefaultConfiguration.max_back_track_time_days,
exclude_merge_branches: (jc === null || jc === void 0 ? void 0 : jc.exclude_merge_branches) || (fc === null || fc === void 0 ? void 0 : fc.exclude_merge_branches) || configuration_1.DefaultConfiguration.exclude_merge_branches,
sort: (jc === null || jc === void 0 ? void 0 : jc.sort) || (fc === null || fc === void 0 ? void 0 : fc.sort) || configuration_1.DefaultConfiguration.sort,
template: (jc === null || jc === void 0 ? void 0 : jc.template) || (fc === null || fc === void 0 ? void 0 : fc.template) || configuration_1.DefaultConfiguration.template,
pr_template: (jc === null || jc === void 0 ? void 0 : jc.pr_template) || (fc === null || fc === void 0 ? void 0 : fc.pr_template) || configuration_1.DefaultConfiguration.pr_template,
empty_template: (jc === null || jc === void 0 ? void 0 : jc.empty_template) || (fc === null || fc === void 0 ? void 0 : fc.empty_template) || configuration_1.DefaultConfiguration.empty_template,
categories: (jc === null || jc === void 0 ? void 0 : jc.categories) || (fc === null || fc === void 0 ? void 0 : fc.categories) || configuration_1.DefaultConfiguration.categories,
ignore_labels: (jc === null || jc === void 0 ? void 0 : jc.ignore_labels) || (fc === null || fc === void 0 ? void 0 : fc.ignore_labels) || configuration_1.DefaultConfiguration.ignore_labels,
label_extractor: (jc === null || jc === void 0 ? void 0 : jc.label_extractor) || (fc === null || fc === void 0 ? void 0 : fc.label_extractor) || configuration_1.DefaultConfiguration.label_extractor,
duplicate_filter: (jc === null || jc === void 0 ? void 0 : jc.duplicate_filter) || (fc === null || fc === void 0 ? void 0 : fc.duplicate_filter) || configuration_1.DefaultConfiguration.duplicate_filter,
transformers: (jc === null || jc === void 0 ? void 0 : jc.transformers) || (fc === null || fc === void 0 ? void 0 : fc.transformers) || configuration_1.DefaultConfiguration.transformers,
tag_resolver: (jc === null || jc === void 0 ? void 0 : jc.tag_resolver) || (fc === null || fc === void 0 ? void 0 : fc.tag_resolver) || configuration_1.DefaultConfiguration.tag_resolver,
base_branches: (jc === null || jc === void 0 ? void 0 : jc.base_branches) || (fc === null || fc === void 0 ? void 0 : fc.base_branches) || configuration_1.DefaultConfiguration.base_branches,
custom_placeholders: (jc === null || jc === void 0 ? void 0 : jc.custom_placeholders) || (fc === null || fc === void 0 ? void 0 : fc.custom_placeholders) || configuration_1.DefaultConfiguration.custom_placeholders,
trim_values: (jc === null || jc === void 0 ? void 0 : jc.trim_values) || (fc === null || fc === void 0 ? void 0 : fc.trim_values) || configuration_1.DefaultConfiguration.trim_values
max_tags_to_fetch: (jc === null || jc === void 0 ? void 0 : jc.max_tags_to_fetch) || (fc === null || fc === void 0 ? void 0 : fc.max_tags_to_fetch) || def.max_tags_to_fetch,
max_pull_requests: (jc === null || jc === void 0 ? void 0 : jc.max_pull_requests) || (fc === null || fc === void 0 ? void 0 : fc.max_pull_requests) || def.max_pull_requests,
max_back_track_time_days: (jc === null || jc === void 0 ? void 0 : jc.max_back_track_time_days) || (fc === null || fc === void 0 ? void 0 : fc.max_back_track_time_days) || def.max_back_track_time_days,
exclude_merge_branches: (jc === null || jc === void 0 ? void 0 : jc.exclude_merge_branches) || (fc === null || fc === void 0 ? void 0 : fc.exclude_merge_branches) || def.exclude_merge_branches,
sort: (jc === null || jc === void 0 ? void 0 : jc.sort) || (fc === null || fc === void 0 ? void 0 : fc.sort) || def.sort,
template: (jc === null || jc === void 0 ? void 0 : jc.template) || (fc === null || fc === void 0 ? void 0 : fc.template) || def.template,
pr_template: (jc === null || jc === void 0 ? void 0 : jc.pr_template) || (fc === null || fc === void 0 ? void 0 : fc.pr_template) || def.pr_template,
empty_template: (jc === null || jc === void 0 ? void 0 : jc.empty_template) || (fc === null || fc === void 0 ? void 0 : fc.empty_template) || def.empty_template,
categories: (jc === null || jc === void 0 ? void 0 : jc.categories) || (fc === null || fc === void 0 ? void 0 : fc.categories) || def.categories,
ignore_labels: (jc === null || jc === void 0 ? void 0 : jc.ignore_labels) || (fc === null || fc === void 0 ? void 0 : fc.ignore_labels) || def.ignore_labels,
label_extractor: (jc === null || jc === void 0 ? void 0 : jc.label_extractor) || (fc === null || fc === void 0 ? void 0 : fc.label_extractor) || def.label_extractor,
duplicate_filter: (jc === null || jc === void 0 ? void 0 : jc.duplicate_filter) || (fc === null || fc === void 0 ? void 0 : fc.duplicate_filter) || def.duplicate_filter,
transformers: (jc === null || jc === void 0 ? void 0 : jc.transformers) || (fc === null || fc === void 0 ? void 0 : fc.transformers) || def.transformers,
tag_resolver: (jc === null || jc === void 0 ? void 0 : jc.tag_resolver) || (fc === null || fc === void 0 ? void 0 : fc.tag_resolver) || def.tag_resolver,
base_branches: (jc === null || jc === void 0 ? void 0 : jc.base_branches) || (fc === null || fc === void 0 ? void 0 : fc.base_branches) || def.base_branches,
custom_placeholders: (jc === null || jc === void 0 ? void 0 : jc.custom_placeholders) || (fc === null || fc === void 0 ? void 0 : fc.custom_placeholders) || def.custom_placeholders,
trim_values: (jc === null || jc === void 0 ? void 0 : jc.trim_values) || (fc === null || fc === void 0 ? void 0 : fc.trim_values) || def.trim_values
};
}
exports.mergeConfiguration = mergeConfiguration;
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+41
View File
@@ -108,3 +108,44 @@ export const DefaultConfiguration: Configuration = {
custom_placeholders: [],
trim_values: false // defines if values are being trimmed prior to inserting
}
export const DefaultCommitConfiguration: Configuration = {
max_tags_to_fetch: DefaultConfiguration.max_tags_to_fetch,
max_pull_requests: DefaultConfiguration.max_pull_requests,
max_back_track_time_days: DefaultConfiguration.max_back_track_time_days,
exclude_merge_branches: DefaultConfiguration.exclude_merge_branches,
sort: DefaultConfiguration.sort,
template: '#{{CHANGELOG}}', // the global template to host the changelog
pr_template: '- #{{TITLE}}', // the per PR template to pick for commit based mode
empty_template: DefaultConfiguration.empty_template,
categories: [
{
title: '## 🚀 Features',
labels: ['feature', 'feat']
},
{
title: '## 🐛 Fixes',
labels: ['fix', 'bug']
},
{
title: '## 🧪 Tests',
labels: ['test']
},
{
title: '## 📦 Other',
labels: []
}
], // the categories to support for the ordering
ignore_labels: DefaultConfiguration.ignore_labels,
label_extractor: [
{
pattern: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)',
target: '$1'
}
],
transformers: DefaultConfiguration.transformers,
tag_resolver: DefaultConfiguration.tag_resolver,
base_branches: DefaultConfiguration.base_branches,
custom_placeholders: DefaultConfiguration.custom_placeholders,
trim_values: DefaultConfiguration.trim_values
}
+7 -4
View File
@@ -1,6 +1,6 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import {mergeConfiguration, parseConfiguration, resolveConfiguration, retrieveRepositoryPath, writeOutput} from './utils'
import {mergeConfiguration, parseConfiguration, resolveConfiguration, resolveMode, retrieveRepositoryPath, writeOutput} from './utils'
import {ReleaseNotesBuilder} from './releaseNotesBuilder'
import {Configuration} from './configuration'
import {GithubRepository} from './repositories/GithubRepository'
@@ -51,8 +51,12 @@ async function run(): Promise<void> {
core.info(`️ No configuration provided. Using Defaults.`)
}
// mode of the action (PR, COMMIT, HYBRID)
const mode = resolveMode(core.getInput('mode'), core.getInput('commitMode') === 'true')
core.info(`️ Running in ${mode} mode.`)
// merge configs, use default values from DefaultConfig on missing definition
const configuration = mergeConfiguration(configJson, configFile)
const configuration = mergeConfiguration(configJson, configFile, mode)
// read in repository inputs
const baseUrl = core.getInput('baseUrl')
@@ -70,7 +74,6 @@ async function run(): Promise<void> {
const fetchReviewers = core.getInput('fetchReviewers') === 'true'
const fetchReleaseInformation = core.getInput('fetchReleaseInformation') === 'true'
const fetchReviews = core.getInput('fetchReviews') === 'true'
const commitMode = core.getInput('commitMode') === 'true'
const exportCache = core.getInput('exportCache') === 'true'
const exportOnly = core.getInput('exportOnly') === 'true'
const cache = core.getInput('cache')
@@ -91,7 +94,7 @@ async function run(): Promise<void> {
fetchReviewers,
fetchReleaseInformation,
fetchReviews,
commitMode,
mode,
exportCache,
exportOnly,
cache,
+6 -3
View File
@@ -91,9 +91,13 @@ export class Commits {
}
async generateCommitPRs(options: Options): Promise<[DiffInfo, PullRequestInfo[]]> {
const {owner, repo, configuration} = options
const diffInfo = await this.getCommitHistory(options)
return convertCommitsToPrs(options, diffInfo)
}
}
export function convertCommitsToPrs(options: Options, diffInfo: DiffInfo): [DiffInfo, PullRequestInfo[]] {
const {owner, repo, configuration} = options
const commits = diffInfo.commitInfo
if (commits.length === 0) {
return [diffInfo, []]
@@ -125,7 +129,6 @@ export class Commits {
})
return [diffInfo, prs]
}
}
/**
* Filters out all commits which match the exclude pattern
+22 -14
View File
@@ -3,7 +3,7 @@ import {PullConfiguration} from './types'
import {TagInfo, Tags} from './tags'
import {failOrError} from './utils'
import {PullRequestInfo, PullRequests} from './pullRequests'
import {Commits, DiffInfo} from './commits'
import {Commits, DefaultDiffInfo, DiffInfo, convertCommitsToPrs} from './commits'
import {BaseRepository} from '../repositories/BaseRepository'
export interface Options {
@@ -17,7 +17,7 @@ export interface Options {
fetchReviewers: boolean // defines if the action should fetch the reviewers for PRs - approved reviewers are not included in the default PR listing
fetchReleaseInformation: boolean // defines if the action should fetch the release information for the from and to tag - e.g. the creation date for the associated release
fetchReviews: boolean // defines if the action should fetch the reviews for the PR.
commitMode: boolean // defines if we use the alternative commit based mode. note: this is only partially supported
mode: 'PR' | 'COMMIT' | 'HYBRID' // defines the mode used. note: the commit or hybrid modes are not fully supported
configuration: PullConfiguration // the configuration as defined in `configuration.ts`
}
@@ -44,7 +44,7 @@ export class PullRequestCollector {
private fetchReviewers = false,
private fetchReleaseInformation = false,
private fetchReviews = false,
private commitMode = false,
private mode: 'PR' | 'COMMIT' | 'HYBRID' = 'PR',
private configuration: PullConfiguration
) {}
@@ -102,29 +102,37 @@ export class PullRequestCollector {
fetchReviewers: this.fetchReviewers,
fetchReleaseInformation: this.fetchReleaseInformation,
fetchReviews: this.fetchReviews,
commitMode: this.commitMode,
mode: this.mode,
configuration: this.configuration
})
}
}
export async function pullData(repositoryUtils: BaseRepository, options: Options): Promise<Data | null> {
let mergedPullRequests: PullRequestInfo[]
let diffInfo: DiffInfo
let mergedPullRequests: PullRequestInfo[] = []
let diffInfo: DiffInfo = Object.assign({}, DefaultDiffInfo)
const commitsApi = new Commits(repositoryUtils)
if (!options.commitMode) {
core.startGroup(`🚀 Load pull requests`)
core.startGroup(`🚀 Load data`)
if (options.mode === 'COMMIT') {
core.info(`🚀 Load commit history (⚠️ Executing experimental commit mode)`)
const [info, prs] = await commitsApi.generateCommitPRs(options)
mergedPullRequests = mergedPullRequests.concat(prs)
diffInfo = info
} else {
// PR mode, HYBRID mode
core.info(`🚀 Load pull requests`)
const pullRequestsApi = new PullRequests(repositoryUtils, commitsApi)
const [info, prs] = await pullRequestsApi.getMergedPullRequests(options)
mergedPullRequests = prs
diffInfo = info
} else {
core.startGroup(`🚀 Load commit history`)
core.info(`⚠️ Executing experimental commit mode`)
const [info, prs] = await commitsApi.generateCommitPRs(options)
mergedPullRequests = prs
diffInfo = info
if (options.mode === 'HYBRID') {
core.info(`🚀 Converting commits to pull requests`)
const [, fakeCommitPrs] = convertCommitsToPrs(options, info)
mergedPullRequests = mergedPullRequests.concat(fakeCommitPrs)
}
}
core.endGroup()
+5 -5
View File
@@ -19,7 +19,7 @@ export interface ReleaseNotesOptions {
fetchReviewers: boolean // defines if the action should fetch the reviewers for PRs - approved reviewers are not included in the default PR listing
fetchReleaseInformation: boolean // defines if the action should fetch the release information for the from and to tag - e.g. the creation date for the associated release
fetchReviews: boolean // defines if the action should fetch the reviews for the PR.
commitMode: boolean // defines if we use the alternative commit based mode. note: this is only partially supported
mode: 'PR' | 'COMMIT' | 'HYBRID' // defines the mode used. note: the commit or hybrid modes are not fully supported
configuration: Configuration // the configuration as defined in `configuration.ts`
repositoryUtils: BaseRepository // the repository implementation used to generate the changelog
}
@@ -46,7 +46,7 @@ export class ReleaseNotesBuilder {
private fetchReviewers = false,
private fetchReleaseInformation = false,
private fetchReviews = false,
private commitMode = false,
private mode: 'PR' | 'COMMIT' | 'HYBRID' = 'PR',
private exportCache = false,
private exportOnly = false,
private cache: string | null = null,
@@ -92,7 +92,7 @@ export class ReleaseNotesBuilder {
this.fetchReviewers,
this.fetchReleaseInformation,
this.fetchReviews,
this.commitMode,
this.mode,
this.configuration
).build()
@@ -110,7 +110,7 @@ export class ReleaseNotesBuilder {
fetchReviewers: this.fetchReviewers,
fetchReleaseInformation: this.fetchReleaseInformation,
fetchReviews: this.fetchReviews,
commitMode: this.commitMode,
mode: this.mode,
configuration: this.configuration,
repositoryUtils: this.repositoryUtils
}
@@ -164,7 +164,7 @@ export class ReleaseNotesBuilder {
fetchReviewers: this.fetchReviewers || orgOptions.fetchReviewers,
fetchReleaseInformation: this.fetchReleaseInformation || orgOptions.fetchReleaseInformation,
fetchReviews: this.fetchReviews || orgOptions.fetchReviews,
commitMode: this.commitMode || orgOptions.commitMode,
mode: this.mode || orgOptions.mode,
configuration: this.configuration || orgOptions.configuration,
repositoryUtils: this.repositoryUtils || orgOptions.repositoryUtils
}
+44 -19
View File
@@ -1,7 +1,7 @@
import * as core from '@actions/core'
import * as fs from 'fs'
import * as path from 'path'
import {Configuration, DefaultConfiguration} from './configuration'
import {Configuration, DefaultCommitConfiguration, DefaultConfiguration} from './configuration'
import moment from 'moment'
import {DiffInfo} from './pr-collector/commits'
import {PullRequestInfo} from './pr-collector/pullRequests'
@@ -117,6 +117,24 @@ export function checkExportedData(exportCache: boolean, cacheInput: string | nul
}
}
export function resolveMode(mode: string | undefined, commitMode: boolean): 'PR' | 'COMMIT' | 'HYBRID' {
if (commitMode === false || mode === undefined) {
if (commitMode === true) {
return 'COMMIT'
} else {
return 'PR'
}
} else {
const upperCaseMode = mode.toUpperCase()
if (upperCaseMode === 'COMMIT') {
return 'COMMIT'
} else if (upperCaseMode === 'HYBRID') {
return 'HYBRID'
}
}
return 'PR'
}
/**
* Retrieves the configuration given the file path, if not found it will fallback to the `DefaultConfiguration`
*/
@@ -173,25 +191,32 @@ export function parseConfiguration(config: string): Configuration | undefined {
/**
* Merges the configurations, will fallback to the DefaultConfiguration value
*/
export function mergeConfiguration(jc?: Configuration, fc?: Configuration): Configuration {
export function mergeConfiguration(jc?: Configuration, fc?: Configuration, mode?: 'PR' | 'COMMIT' | 'HYBRID'): Configuration {
let def: Configuration
if (mode === 'COMMIT') {
def = DefaultCommitConfiguration
} else {
def = DefaultConfiguration
}
return {
max_tags_to_fetch: jc?.max_tags_to_fetch || fc?.max_tags_to_fetch || DefaultConfiguration.max_tags_to_fetch,
max_pull_requests: jc?.max_pull_requests || fc?.max_pull_requests || DefaultConfiguration.max_pull_requests,
max_back_track_time_days: jc?.max_back_track_time_days || fc?.max_back_track_time_days || DefaultConfiguration.max_back_track_time_days,
exclude_merge_branches: jc?.exclude_merge_branches || fc?.exclude_merge_branches || DefaultConfiguration.exclude_merge_branches,
sort: jc?.sort || fc?.sort || DefaultConfiguration.sort,
template: jc?.template || fc?.template || DefaultConfiguration.template,
pr_template: jc?.pr_template || fc?.pr_template || DefaultConfiguration.pr_template,
empty_template: jc?.empty_template || fc?.empty_template || DefaultConfiguration.empty_template,
categories: jc?.categories || fc?.categories || DefaultConfiguration.categories,
ignore_labels: jc?.ignore_labels || fc?.ignore_labels || DefaultConfiguration.ignore_labels,
label_extractor: jc?.label_extractor || fc?.label_extractor || DefaultConfiguration.label_extractor,
duplicate_filter: jc?.duplicate_filter || fc?.duplicate_filter || DefaultConfiguration.duplicate_filter,
transformers: jc?.transformers || fc?.transformers || DefaultConfiguration.transformers,
tag_resolver: jc?.tag_resolver || fc?.tag_resolver || DefaultConfiguration.tag_resolver,
base_branches: jc?.base_branches || fc?.base_branches || DefaultConfiguration.base_branches,
custom_placeholders: jc?.custom_placeholders || fc?.custom_placeholders || DefaultConfiguration.custom_placeholders,
trim_values: jc?.trim_values || fc?.trim_values || DefaultConfiguration.trim_values
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,
max_back_track_time_days: jc?.max_back_track_time_days || fc?.max_back_track_time_days || def.max_back_track_time_days,
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,
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,
label_extractor: jc?.label_extractor || fc?.label_extractor || def.label_extractor,
duplicate_filter: jc?.duplicate_filter || fc?.duplicate_filter || def.duplicate_filter,
transformers: jc?.transformers || fc?.transformers || def.transformers,
tag_resolver: jc?.tag_resolver || fc?.tag_resolver || def.tag_resolver,
base_branches: jc?.base_branches || fc?.base_branches || def.base_branches,
custom_placeholders: jc?.custom_placeholders || fc?.custom_placeholders || def.custom_placeholders,
trim_values: jc?.trim_values || fc?.trim_values || def.trim_values
}
}