Skip to content

Commit

Permalink
- expand log messages
Browse files Browse the repository at this point in the history
- introduce test case to verify the inclusion of the open PR as part of the standard PR set
  • Loading branch information
mikepenz committed Apr 8, 2022
1 parent c15aea0 commit ef2680b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 21 deletions.
11 changes: 5 additions & 6 deletions __tests__/releaseNotesBuilder.test.ts
Expand Up @@ -238,11 +238,10 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
)
})


it('Verify inclusion of open PRs', async () => {
it('Verify default inclusion of open PRs', async () => {
const configuration = resolveConfiguration(
'',
'configs_test/configuration_commits_emoji.json'
'configs_test/configuration_including_open.json'
)
const releaseNotesBuilder = new ReleaseNotesBuilder(
null, // baseUrl
Expand All @@ -255,13 +254,13 @@ it('Verify inclusion of open PRs', async () => {
true, // includeOpen
false, // failOnError
false, // ignorePrePrelease
true, // commitMode
false, // commitMode
configuration // configuration
)

const changeLog = await releaseNotesBuilder.build()
console.log(changeLog)
expect(changeLog).toStrictEqual(
``
`## 🚀 Features\n\n- A feature to be going to v2 (nr3) (#3) merged\n- New feature to keep open (nr5) (#7) open\n\n\n\n\nUncategorized\n\n\n\nOpen\n- New feature to keep open (nr5) (#7) open\n`
)
})
})
10 changes: 10 additions & 0 deletions configs_test/configuration_including_open.json
@@ -0,0 +1,10 @@
{
"categories": [
{
"title": "## 🚀 Features",
"labels": ["feature"]
}
],
"template": "${{CHANGELOG}}\n\n\nUncategorized\n${{UNCATEGORIZED}}\n\n\nOpen\n${{OPEN}}",
"pr_template": "- ${{TITLE}} (#${{NUMBER}}) ${{STATUS}}"
}
15 changes: 8 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/pullRequests.ts
Expand Up @@ -97,7 +97,7 @@ export class PullRequests {
repo: string,
maxPullRequests: number
): Promise<PullRequestInfo[]> {
const mergedPRs: PullRequestInfo[] = []
const openPrs: PullRequestInfo[] = []
const options = this.octokit.pulls.list.endpoint.merge({
owner,
repo,
Expand All @@ -111,21 +111,21 @@ export class PullRequests {
const prs: PullsListData = response.data as PullsListData

for (const pr of prs) {
mergedPRs.push(mapPullRequest(pr, 'open'))
openPrs.push(mapPullRequest(pr, 'open'))
}

const firstPR = prs[0]
if (firstPR === undefined || mergedPRs.length >= maxPullRequests) {
if (mergedPRs.length >= maxPullRequests) {
if (firstPR === undefined || openPrs.length >= maxPullRequests) {
if (openPrs.length >= maxPullRequests) {
core.warning(`⚠️ Reached 'maxPullRequests' count ${maxPullRequests}`)
}

// bail out early to not keep iterating on PRs super old
return sortPullRequests(mergedPRs, true)
return sortPullRequests(openPrs, true)
}
}

return sortPullRequests(mergedPRs, true)
return sortPullRequests(openPrs, true)
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/releaseNotes.ts
Expand Up @@ -150,11 +150,15 @@ export class ReleaseNotes {
)

core.info(
`ℹ️ Retrieved ${pullRequests.length} open PRs for ${owner}/${repo}`
`ℹ️ Retrieved ${openPullRequests.length} open PRs for ${owner}/${repo}`
)

// all pull requests
allPullRequests = allPullRequests.concat(openPullRequests)

core.info(
`ℹ️ Retrieved ${allPullRequests.length} total PRs for ${owner}/${repo}`
)
}

// retrieve base branches we allow
Expand Down

0 comments on commit ef2680b

Please sign in to comment.