- 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:
@@ -238,11 +238,10 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Verify default inclusion of open PRs', async () => {
|
||||||
it('Verify inclusion of open PRs', async () => {
|
|
||||||
const configuration = resolveConfiguration(
|
const configuration = resolveConfiguration(
|
||||||
'',
|
'',
|
||||||
'configs_test/configuration_commits_emoji.json'
|
'configs_test/configuration_including_open.json'
|
||||||
)
|
)
|
||||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||||
null, // baseUrl
|
null, // baseUrl
|
||||||
@@ -255,13 +254,13 @@ it('Verify inclusion of open PRs', async () => {
|
|||||||
true, // includeOpen
|
true, // includeOpen
|
||||||
false, // failOnError
|
false, // failOnError
|
||||||
false, // ignorePrePrelease
|
false, // ignorePrePrelease
|
||||||
true, // commitMode
|
false, // commitMode
|
||||||
configuration // configuration
|
configuration // configuration
|
||||||
)
|
)
|
||||||
|
|
||||||
const changeLog = await releaseNotesBuilder.build()
|
const changeLog = await releaseNotesBuilder.build()
|
||||||
console.log(changeLog)
|
console.log(changeLog)
|
||||||
expect(changeLog).toStrictEqual(
|
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}}"
|
||||||
|
}
|
||||||
+8
-7
@@ -515,7 +515,7 @@ class PullRequests {
|
|||||||
getOpen(owner, repo, maxPullRequests) {
|
getOpen(owner, repo, maxPullRequests) {
|
||||||
var e_2, _a;
|
var e_2, _a;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const mergedPRs = [];
|
const openPrs = [];
|
||||||
const options = this.octokit.pulls.list.endpoint.merge({
|
const options = this.octokit.pulls.list.endpoint.merge({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@@ -529,15 +529,15 @@ class PullRequests {
|
|||||||
const response = _c.value;
|
const response = _c.value;
|
||||||
const prs = response.data;
|
const prs = response.data;
|
||||||
for (const pr of prs) {
|
for (const pr of prs) {
|
||||||
mergedPRs.push(mapPullRequest(pr, 'open'));
|
openPrs.push(mapPullRequest(pr, 'open'));
|
||||||
}
|
}
|
||||||
const firstPR = prs[0];
|
const firstPR = prs[0];
|
||||||
if (firstPR === undefined || mergedPRs.length >= maxPullRequests) {
|
if (firstPR === undefined || openPrs.length >= maxPullRequests) {
|
||||||
if (mergedPRs.length >= maxPullRequests) {
|
if (openPrs.length >= maxPullRequests) {
|
||||||
core.warning(`⚠️ Reached 'maxPullRequests' count ${maxPullRequests}`);
|
core.warning(`⚠️ Reached 'maxPullRequests' count ${maxPullRequests}`);
|
||||||
}
|
}
|
||||||
// bail out early to not keep iterating on PRs super old
|
// 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; }
|
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
|
// retrieve all open pull requests
|
||||||
const openPullRequests = yield pullRequestsApi.getOpen(owner, repo, configuration.max_pull_requests ||
|
const openPullRequests = yield pullRequestsApi.getOpen(owner, repo, configuration.max_pull_requests ||
|
||||||
configuration_1.DefaultConfiguration.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
|
// all pull requests
|
||||||
allPullRequests = allPullRequests.concat(openPullRequests);
|
allPullRequests = allPullRequests.concat(openPullRequests);
|
||||||
|
core.info(`ℹ️ Retrieved ${allPullRequests.length} total PRs for ${owner}/${repo}`);
|
||||||
}
|
}
|
||||||
// retrieve base branches we allow
|
// retrieve base branches we allow
|
||||||
const baseBranches = configuration.base_branches || configuration_1.DefaultConfiguration.base_branches;
|
const baseBranches = configuration.base_branches || configuration_1.DefaultConfiguration.base_branches;
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+6
-6
@@ -97,7 +97,7 @@ export class PullRequests {
|
|||||||
repo: string,
|
repo: string,
|
||||||
maxPullRequests: number
|
maxPullRequests: number
|
||||||
): Promise<PullRequestInfo[]> {
|
): Promise<PullRequestInfo[]> {
|
||||||
const mergedPRs: PullRequestInfo[] = []
|
const openPrs: PullRequestInfo[] = []
|
||||||
const options = this.octokit.pulls.list.endpoint.merge({
|
const options = this.octokit.pulls.list.endpoint.merge({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@@ -111,21 +111,21 @@ export class PullRequests {
|
|||||||
const prs: PullsListData = response.data as PullsListData
|
const prs: PullsListData = response.data as PullsListData
|
||||||
|
|
||||||
for (const pr of prs) {
|
for (const pr of prs) {
|
||||||
mergedPRs.push(mapPullRequest(pr, 'open'))
|
openPrs.push(mapPullRequest(pr, 'open'))
|
||||||
}
|
}
|
||||||
|
|
||||||
const firstPR = prs[0]
|
const firstPR = prs[0]
|
||||||
if (firstPR === undefined || mergedPRs.length >= maxPullRequests) {
|
if (firstPR === undefined || openPrs.length >= maxPullRequests) {
|
||||||
if (mergedPRs.length >= maxPullRequests) {
|
if (openPrs.length >= maxPullRequests) {
|
||||||
core.warning(`⚠️ Reached 'maxPullRequests' count ${maxPullRequests}`)
|
core.warning(`⚠️ Reached 'maxPullRequests' count ${maxPullRequests}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// bail out early to not keep iterating on PRs super old
|
// 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
@@ -150,11 +150,15 @@ export class ReleaseNotes {
|
|||||||
)
|
)
|
||||||
|
|
||||||
core.info(
|
core.info(
|
||||||
`ℹ️ Retrieved ${pullRequests.length} open PRs for ${owner}/${repo}`
|
`ℹ️ Retrieved ${openPullRequests.length} open PRs for ${owner}/${repo}`
|
||||||
)
|
)
|
||||||
|
|
||||||
// all pull requests
|
// all pull requests
|
||||||
allPullRequests = allPullRequests.concat(openPullRequests)
|
allPullRequests = allPullRequests.concat(openPullRequests)
|
||||||
|
|
||||||
|
core.info(
|
||||||
|
`ℹ️ Retrieved ${allPullRequests.length} total PRs for ${owner}/${repo}`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieve base branches we allow
|
// retrieve base branches we allow
|
||||||
|
|||||||
Reference in New Issue
Block a user