- expand log messages

- introduce test case to verify the inclusion of the open PR as part of the standard PR set
This commit is contained in:
Mike Penz
2022-04-08 11:00:39 +02:00
parent 85af6a8181
commit 6211ea4995
6 changed files with 35 additions and 21 deletions
+5 -6
View File
@@ -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
@@ -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`
)
})
})
@@ -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}}"
}
Generated Vendored
+8 -7
View File
@@ -515,7 +515,7 @@ class PullRequests {
getOpen(owner, repo, maxPullRequests) {
var e_2, _a;
return __awaiter(this, void 0, void 0, function* () {
const mergedPRs = [];
const openPrs = [];
const options = this.octokit.pulls.list.endpoint.merge({
owner,
repo,
@@ -529,15 +529,15 @@ class PullRequests {
const response = _c.value;
const prs = response.data;
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);
}
}
}
@@ -548,7 +548,7 @@ class PullRequests {
}
finally { if (e_2) throw e_2.error; }
}
return sortPullRequests(mergedPRs, true);
return sortPullRequests(openPrs, true);
});
}
}
@@ -750,9 +750,10 @@ class ReleaseNotes {
// retrieve all open pull requests
const openPullRequests = yield pullRequestsApi.getOpen(owner, repo, configuration.max_pull_requests ||
configuration_1.DefaultConfiguration.max_pull_requests);
core.info(`️ Retrieved ${pullRequests.length} open PRs for ${owner}/${repo}`);
core.info(`️ 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
const baseBranches = configuration.base_branches || configuration_1.DefaultConfiguration.base_branches;
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+6 -6
View File
@@ -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,
@@ -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)
}
}
+5 -1
View File
@@ -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