- read in labels from pull requests

- stop processing pull requests as soon as we reached a PR which was last changed before the relevant date range
- return filtered pull requests
This commit is contained in:
Mike Penz
2020-10-16 09:53:08 +02:00
parent 8944338c36
commit 8dd6d28fd5
2 changed files with 11 additions and 1 deletions
+10
View File
@@ -11,6 +11,7 @@ export interface PullRequestInfo {
mergedAt: moment.Moment
author: string
repoName: string
labels: Array<string>
body: string
}
@@ -28,6 +29,7 @@ export class PullRequests {
mergedAt: moment(pr.data.merged_at),
author: pr.data.user.login,
repoName: pr.data.base.repo.full_name,
labels: pr.data.labels.map(function (label) { return label.name }),
body: pr.data.body
}
} catch (e) {
@@ -54,6 +56,13 @@ export class PullRequests {
for await (const response of this.octokit.paginate.iterator(options)) {
type PullsListData = RestEndpointMethodTypes["pulls"]["list"]["response"]["data"]
const prs: PullsListData = response.data as PullsListData
const firstPR = prs[0]
if(firstPR.merged_at && fromDate.isAfter(moment(firstPR.merged_at))) {
// bail out early to not keep iterating on PRs super old
return this.sortPullRequests(mergedPRs)
}
prs.filter(
pr =>
!!pr.merged_at &&
@@ -67,6 +76,7 @@ export class PullRequests {
mergedAt: moment(pr.merged_at),
author: pr.user.login,
repoName: pr.base.repo.full_name,
labels: pr.labels.map(function (label) { return label.name }),
body: pr.body
})
})
+1 -1
View File
@@ -102,7 +102,7 @@ export class ReleaseNotes {
}
}
return pullRequests
return filteredPullRequests
}
private getFormatedChanges(pullRequests: PullRequestInfo[], formatter: (pr?: PullRequestInfo) => string): string {