Implement commit_template
This commit is contained in:
@@ -367,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 = [
|
||||
{
|
||||
@@ -408,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)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user