- introduce more placeholders (milestone, labels, asignees, reviewers)
- update testcase to check new placeholders
This commit is contained in:
+11
-3
@@ -88,7 +88,7 @@ it('Should match generated changelog (unspecified fromTag)', async () => {
|
||||
it('Should match generated changelog (refs)', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const configuration = readConfiguration('configuration.json')!!
|
||||
const configuration = readConfiguration('configs/configuration_all_placeholders.json')!!
|
||||
const releaseNotes = new ReleaseNotes({
|
||||
owner: 'mikepenz',
|
||||
repo: 'release-changelog-builder-action',
|
||||
@@ -102,8 +102,16 @@ it('Should match generated changelog (refs)', async () => {
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 🧪 Tests
|
||||
|
||||
- [CI] Specify Test Case
|
||||
- PR: #10
|
||||
[CI] Specify Test Case
|
||||
10
|
||||
https://github.com/mikepenz/release-changelog-builder-action/pull/10
|
||||
2020-10-16T13:59:36.000Z
|
||||
mikepenz
|
||||
test
|
||||
1.0.0
|
||||
- specify test case
|
||||
mikepenz, nhoelzl
|
||||
nhoelzl
|
||||
|
||||
`)
|
||||
})
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"pr_template": "${{TITLE}}\n${{NUMBER}}\n${{URL}}\n${{MERGED_AT}}\n${{AUTHOR}}\n${{LABELS}}\n${{MILESTONE}}\n${{BODY}}\n${{ASIGNEES}}\n${{REVIEWERS}}"
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"categories": [
|
||||
{
|
||||
"title": "## 🚀 Features",
|
||||
"labels": ["feature"]
|
||||
},
|
||||
{
|
||||
"title": "## 🦄 Internal Features",
|
||||
"labels": ["internal"]
|
||||
},
|
||||
{
|
||||
"title": "## 🐛 Fixes",
|
||||
"labels": ["fix"]
|
||||
},
|
||||
{
|
||||
"title": "## 🧪 Tests",
|
||||
"labels": ["test"]
|
||||
}
|
||||
],
|
||||
"sort": "ASC",
|
||||
"template": "${{CHANGELOG}}",
|
||||
"pr_template": "- ${{TITLE}}\n - PR: #${{NUMBER}}",
|
||||
"empty_template": "- no changes"
|
||||
}
|
||||
+22
-3
@@ -12,7 +12,10 @@ export interface PullRequestInfo {
|
||||
author: string
|
||||
repoName: string
|
||||
labels: string[]
|
||||
milestone: string
|
||||
body: string
|
||||
assignees: string[]
|
||||
requestedReviewers: string[]
|
||||
}
|
||||
|
||||
export class PullRequests {
|
||||
@@ -40,7 +43,16 @@ export class PullRequests {
|
||||
labels: pr.data.labels.map(function (label) {
|
||||
return label.name
|
||||
}),
|
||||
body: pr.data.body
|
||||
milestone: pr.data.milestone?.title,
|
||||
body: pr.data.body,
|
||||
assignees: pr.data.assignees?.map(function (asignee) {
|
||||
return asignee.login
|
||||
}),
|
||||
requestedReviewers: pr.data.requested_reviewers?.map(function (
|
||||
reviewer
|
||||
) {
|
||||
return reviewer.login
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
core.warning(`Cannot find PR ${owner}/${repo}#${prNumber} - ${e.message}`)
|
||||
@@ -76,10 +88,17 @@ export class PullRequests {
|
||||
mergedAt: moment(pr.merged_at),
|
||||
author: pr.user.login,
|
||||
repoName: pr.base.repo.full_name,
|
||||
labels: pr.labels.map(function (label) {
|
||||
labels: pr.labels?.map(function (label) {
|
||||
return label.name
|
||||
}),
|
||||
body: pr.body
|
||||
milestone: pr.milestone?.title,
|
||||
body: pr.body,
|
||||
assignees: pr.assignees?.map(function (asignee) {
|
||||
return asignee.login
|
||||
}),
|
||||
requestedReviewers: pr.requested_reviewers?.map(function (reviewer) {
|
||||
return reviewer.login
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+13
-4
@@ -38,10 +38,9 @@ export function buildChangelog(
|
||||
|
||||
// bring PRs into the order of categories
|
||||
const categorized = new Map<Category, string[]>()
|
||||
if (config.categories) {
|
||||
for (const category of config.categories) {
|
||||
categorized.set(category, [])
|
||||
}
|
||||
const categories = config.categories ?? DefaultConfiguration.categories
|
||||
for (const category of categories) {
|
||||
categorized.set(category, [])
|
||||
}
|
||||
const uncategorized: string[] = []
|
||||
|
||||
@@ -107,7 +106,17 @@ function fillTemplate(pr: PullRequestInfo, template: string): string {
|
||||
transformed = transformed.replace('${{URL}}', pr.htmlURL)
|
||||
transformed = transformed.replace('${{MERGED_AT}}', pr.mergedAt.toISOString())
|
||||
transformed = transformed.replace('${{AUTHOR}}', pr.author)
|
||||
transformed = transformed.replace('${{LABELS}}', pr.labels?.join(', ') ?? '')
|
||||
transformed = transformed.replace('${{MILESTONE}}', pr.milestone ?? '')
|
||||
transformed = transformed.replace('${{BODY}}', pr.body)
|
||||
transformed = transformed.replace(
|
||||
'${{ASIGNEES}}',
|
||||
pr.assignees?.join(', ') ?? ''
|
||||
)
|
||||
transformed = transformed.replace(
|
||||
'${{REVIEWERS}}',
|
||||
pr.requestedReviewers?.join(', ') ?? ''
|
||||
)
|
||||
return transformed
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user