Skip to content

Commit

Permalink
- introduce new mode configuration (replaces commitMode) with the o…
Browse files Browse the repository at this point in the history
…ption for `PR`, `COMMIT` or `HYBRID` (whereas hybrid has commits and PRs alongside)

- introduce new default commit configuration automatically used if `COMMIT` mode is configured. this uses a label extractor to support conventional commits
  • Loading branch information
mikepenz authored Mar 2, 2024
1 parent 98e699a commit db235a6
Show file tree
Hide file tree
Showing 15 changed files with 390 additions and 226 deletions.
28 changes: 14 additions & 14 deletions __tests__/gitea/releaseNotesBuilderGitea.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
39 changes: 20 additions & 19 deletions __tests__/gitea/releaseNotesBuilderPullGitea.test.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions __tests__/releaseNotesBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit db235a6

Please sign in to comment.