- add additional settings to ensure we won't spend the whole API quota if a merge included non anticipated commits
This commit is contained in:
+21
-3
@@ -52,7 +52,8 @@ export class PullRequests {
|
||||
owner: string,
|
||||
repo: string,
|
||||
fromDate: moment.Moment,
|
||||
toDate: moment.Moment // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
toDate: moment.Moment, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
maxPullRequests: number
|
||||
): Promise<PullRequestInfo[]> {
|
||||
const mergedPRs: PullRequestInfo[] = []
|
||||
const options = this.octokit.pulls.list.endpoint.merge({
|
||||
@@ -83,7 +84,11 @@ export class PullRequests {
|
||||
}
|
||||
|
||||
const firstPR = prs[0]
|
||||
if (firstPR.merged_at && fromDate.isAfter(moment(firstPR.merged_at))) {
|
||||
if (firstPR.merged_at && fromDate.isAfter(moment(firstPR.merged_at)) || mergedPRs.length >= maxPullRequests) {
|
||||
if( mergedPRs.length >= maxPullRequests ) {
|
||||
core.info(`Reached 'maxPullRequests' count ${maxPullRequests}`)
|
||||
}
|
||||
|
||||
// bail out early to not keep iterating on PRs super old
|
||||
return sortPullRequests(mergedPRs, true)
|
||||
}
|
||||
@@ -92,11 +97,24 @@ export class PullRequests {
|
||||
return sortPullRequests(mergedPRs, true)
|
||||
}
|
||||
|
||||
filterCommits(commits: CommitInfo[]): CommitInfo[] {
|
||||
filterCommits(commits: CommitInfo[], excludeMergeBranches: string[]): CommitInfo[] {
|
||||
const prRegex = /Merge pull request #(\d+)/
|
||||
const filteredCommits = []
|
||||
|
||||
for (const commit of commits) {
|
||||
if(excludeMergeBranches) {
|
||||
let matched = false
|
||||
for (const excludeMergeBranch of excludeMergeBranches) {
|
||||
if(commit.summary.includes(excludeMergeBranch)) {
|
||||
matched = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if(matched) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
const match = commit.summary.match(prRegex)
|
||||
if (!match) {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user