- introduce new flag to include open PRs into the changelog
- only fetch open with this flag - expand pull request spec with - status, created at timestamp - expand definition for placeholder patterns in the changelog
This commit is contained in:
+35
-3
@@ -95,6 +95,7 @@ export function buildChangelog(
|
||||
|
||||
const categorizedPrs: string[] = []
|
||||
const ignoredPrs: string[] = []
|
||||
const openPrs: string[] = []
|
||||
const uncategorizedPrs: string[] = []
|
||||
|
||||
// bring elements in order
|
||||
@@ -109,6 +110,10 @@ export function buildChangelog(
|
||||
continue
|
||||
}
|
||||
|
||||
if (pr.status === 'open') {
|
||||
openPrs.push(body)
|
||||
}
|
||||
|
||||
let matched = false
|
||||
for (const [category, pullRequests] of categorized) {
|
||||
// check if any exclude label matches
|
||||
@@ -206,6 +211,20 @@ export function buildChangelog(
|
||||
}
|
||||
core.setOutput('uncategorized_prs', uncategorizedPrs.length)
|
||||
|
||||
let changelogOpen = ''
|
||||
if (openPrs.length > 0) {
|
||||
for (const pr of openPrs) {
|
||||
changelogOpen = `${changelogOpen + pr}\n`
|
||||
}
|
||||
core.info(`✒️ Wrote ${openPrs.length} open pull requests down`)
|
||||
if (core.isDebug()) {
|
||||
for (const pr of openPrs) {
|
||||
core.debug(` ${pr}`)
|
||||
}
|
||||
}
|
||||
core.setOutput('open_prs', openPrs.length)
|
||||
}
|
||||
|
||||
let changelogIgnored = ''
|
||||
for (const pr of ignoredPrs) {
|
||||
changelogIgnored = `${changelogIgnored + pr}\n`
|
||||
@@ -227,6 +246,10 @@ export function buildChangelog(
|
||||
/\${{UNCATEGORIZED}}/g,
|
||||
changelogUncategorized
|
||||
)
|
||||
transformedChangelog = transformedChangelog.replace(
|
||||
/\${{OPEN}}/g,
|
||||
changelogOpen
|
||||
)
|
||||
transformedChangelog = transformedChangelog.replace(
|
||||
/\${{IGNORED}}/g,
|
||||
changelogIgnored
|
||||
@@ -241,6 +264,10 @@ export function buildChangelog(
|
||||
/\${{UNCATEGORIZED_COUNT}}/g,
|
||||
uncategorizedPrs.length.toString()
|
||||
)
|
||||
transformedChangelog = transformedChangelog.replace(
|
||||
/\${{OPEN_COUNT}}/g,
|
||||
openPrs.length.toString()
|
||||
)
|
||||
transformedChangelog = transformedChangelog.replace(
|
||||
/\${{IGNORED_COUNT}}/g,
|
||||
ignoredPrs.length.toString()
|
||||
@@ -283,15 +310,20 @@ function fillTemplate(pr: PullRequestInfo, template: string): string {
|
||||
transformed = transformed.replace(/\${{NUMBER}}/g, pr.number.toString())
|
||||
transformed = transformed.replace(/\${{TITLE}}/g, pr.title)
|
||||
transformed = transformed.replace(/\${{URL}}/g, pr.htmlURL)
|
||||
transformed = transformed.replace(/\${{STATUS}}/g, pr.status)
|
||||
transformed = transformed.replace(
|
||||
/\${{CREATED_AT}}/g,
|
||||
pr.createdAt.toISOString()
|
||||
)
|
||||
transformed = transformed.replace(
|
||||
/\${{MERGED_AT}}/g,
|
||||
pr.mergedAt.toISOString()
|
||||
pr.mergedAt?.toISOString() || ''
|
||||
)
|
||||
transformed = transformed.replace(/\${{MERGE_SHA}}/g, pr.mergeCommitSha)
|
||||
transformed = transformed.replace(/\${{AUTHOR}}/g, pr.author)
|
||||
transformed = transformed.replace(
|
||||
/\${{LABELS}}/g,
|
||||
[...pr.labels]?.join(', ') || ''
|
||||
[...pr.labels]?.filter(l => !l.startsWith('##rcba-'))?.join(', ') || ''
|
||||
)
|
||||
transformed = transformed.replace(/\${{MILESTONE}}/g, pr.milestone || '')
|
||||
transformed = transformed.replace(/\${{BODY}}/g, pr.body)
|
||||
@@ -384,7 +416,7 @@ function extractValues(
|
||||
|
||||
if (extractor.onProperty !== undefined) {
|
||||
let results: string[] = []
|
||||
const list: ('title' | 'author' | 'milestone' | 'body')[] =
|
||||
const list: ('title' | 'author' | 'milestone' | 'body' | 'status')[] =
|
||||
extractor.onProperty
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user