Skip to content

Commit

Permalink
Define PR title once
Browse files Browse the repository at this point in the history
  • Loading branch information
robbinjanssen committed Mar 6, 2022
1 parent eb9cfe3 commit 41b8bf1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
17 changes: 11 additions & 6 deletions dist/index.js
Expand Up @@ -129351,19 +129351,24 @@ const generateChangeLog = (mergedPullRequests, config) => {
if (category.pullRequests.length === 0) {
continue
}
const categoryTitle = template(config['category-template'], {
$TITLE: category.title,
})

// Add the category title to the changelog.
changeLog.push(
template(config['category-template'], { $TITLE: category.title }),
'\n\n'
)

// Define the pull requests into a single string.
const pullRequestString = pullRequestToString(category.pullRequests)

// Determine the collapse status.
const shouldCollapse =
category['collapse-after'] !== 0 &&
category.pullRequests.length > category['collapse-after']

// Add the pull requests to the changelog.
if (shouldCollapse) {
changeLog.push(
categoryTitle,
'\n\n',
'<details>',
'\n',
`<summary>${category.pullRequests.length} changes</summary>`,
Expand All @@ -129373,7 +129378,7 @@ const generateChangeLog = (mergedPullRequests, config) => {
'</details>'
)
} else {
changeLog.push(categoryTitle, '\n\n', pullRequestString)
changeLog.push(pullRequestString)
}

if (index + 1 !== categorizedPullRequests.length) changeLog.push('\n\n')
Expand Down
17 changes: 11 additions & 6 deletions lib/releases.js
Expand Up @@ -241,19 +241,24 @@ const generateChangeLog = (mergedPullRequests, config) => {
if (category.pullRequests.length === 0) {
continue
}
const categoryTitle = template(config['category-template'], {
$TITLE: category.title,
})

// Add the category title to the changelog.
changeLog.push(
template(config['category-template'], { $TITLE: category.title }),
'\n\n'
)

// Define the pull requests into a single string.
const pullRequestString = pullRequestToString(category.pullRequests)

// Determine the collapse status.
const shouldCollapse =
category['collapse-after'] !== 0 &&
category.pullRequests.length > category['collapse-after']

// Add the pull requests to the changelog.
if (shouldCollapse) {
changeLog.push(
categoryTitle,
'\n\n',
'<details>',
'\n',
`<summary>${category.pullRequests.length} changes</summary>`,
Expand All @@ -263,7 +268,7 @@ const generateChangeLog = (mergedPullRequests, config) => {
'</details>'
)
} else {
changeLog.push(categoryTitle, '\n\n', pullRequestString)
changeLog.push(pullRequestString)
}

if (index + 1 !== categorizedPullRequests.length) changeLog.push('\n\n')
Expand Down

0 comments on commit 41b8bf1

Please sign in to comment.