- introduce proper configuration for fetchReviews
- drop no longer needed limiting of PRs - retrieve state from PR review comment
This commit is contained in:
@@ -40,6 +40,7 @@ async function run(): Promise<void> {
|
||||
const failOnError = core.getInput('failOnError') === 'true'
|
||||
const fetchReviewers = core.getInput('fetchReviewers') === 'true'
|
||||
const fetchReleaseInformation = core.getInput('fetchReleaseInformation') === 'true'
|
||||
const fetchReviews = core.getInput('fetchReviews') === 'true'
|
||||
const commitMode = core.getInput('commitMode') === 'true'
|
||||
|
||||
const result = await new ReleaseNotesBuilder(
|
||||
@@ -55,6 +56,7 @@ async function run(): Promise<void> {
|
||||
ignorePreReleases,
|
||||
fetchReviewers,
|
||||
fetchReleaseInformation,
|
||||
fetchReviews,
|
||||
commitMode,
|
||||
configuration
|
||||
).build()
|
||||
|
||||
+12
-1
@@ -31,6 +31,16 @@ export interface CommentInfo {
|
||||
submittedAt: moment.Moment | undefined
|
||||
author: string
|
||||
body: string
|
||||
state: string | undefined
|
||||
}
|
||||
|
||||
export const EMPTY_COMMENT_INFO: CommentInfo = {
|
||||
id: 0,
|
||||
htmlURL: '',
|
||||
submittedAt: undefined,
|
||||
author: '',
|
||||
body: '',
|
||||
state: undefined
|
||||
}
|
||||
|
||||
type PullData = RestEndpointMethodTypes['pulls']['get']['response']['data']
|
||||
@@ -251,5 +261,6 @@ const mapComment = (comment: Unpacked<PullReviewsData>): CommentInfo => ({
|
||||
htmlURL: comment.html_url,
|
||||
submittedAt: comment.submitted_at ? moment(comment.submitted_at) : undefined,
|
||||
author: comment.user?.login || '',
|
||||
body: comment.body
|
||||
body: comment.body,
|
||||
state: comment.state
|
||||
})
|
||||
|
||||
+2
-2
@@ -16,6 +16,7 @@ export interface ReleaseNotesOptions {
|
||||
failOnError: boolean // defines if we should fail the action in case of an error
|
||||
fetchReviewers: boolean // defines if the action should fetch the reviewers for PRs - approved reviewers are not included in the default PR listing
|
||||
fetchReleaseInformation: boolean // defines if the action should fetch the release information for the from and to tag - e.g. the creation date for the associated release
|
||||
fetchReviews: boolean // defines if the action should fetch the reviews for the PR.
|
||||
commitMode: boolean // defines if we use the alternative commit based mode. note: this is only partially supported
|
||||
configuration: Configuration // the configuration as defined in `configuration.ts`
|
||||
}
|
||||
@@ -94,8 +95,7 @@ export class ReleaseNotes {
|
||||
}
|
||||
|
||||
private async getMergedPullRequests(octokit: Octokit): Promise<[DiffInfo, PullRequestInfo[]]> {
|
||||
const {owner, repo, includeOpen, fetchReviewers, configuration} = this.options
|
||||
const fetchReviews = true // TEMPORARY!!
|
||||
const {owner, repo, includeOpen, fetchReviewers, fetchReviews, configuration} = this.options
|
||||
|
||||
const diffInfo = await this.getCommitHistory(octokit)
|
||||
const commits = diffInfo.commitInfo
|
||||
|
||||
@@ -20,6 +20,7 @@ export class ReleaseNotesBuilder {
|
||||
private ignorePreReleases: boolean,
|
||||
private fetchReviewers: boolean = false,
|
||||
private fetchReleaseInformation: boolean = false,
|
||||
private fetchReviews: boolean = false,
|
||||
private commitMode: boolean,
|
||||
private configuration: Configuration
|
||||
) {}
|
||||
@@ -117,6 +118,7 @@ export class ReleaseNotesBuilder {
|
||||
failOnError: this.failOnError,
|
||||
fetchReviewers: this.fetchReviewers,
|
||||
fetchReleaseInformation: this.fetchReleaseInformation,
|
||||
fetchReviews: this.fetchReviews,
|
||||
commitMode: this.commitMode,
|
||||
configuration: this.configuration
|
||||
}
|
||||
|
||||
+2
-16
@@ -1,6 +1,6 @@
|
||||
import * as core from '@actions/core'
|
||||
import {Category, DefaultConfiguration, Extractor, Placeholder, Transformer} from './configuration'
|
||||
import {CommentInfo, PullRequestInfo, sortPullRequests} from './pullRequests'
|
||||
import {CommentInfo, EMPTY_COMMENT_INFO, PullRequestInfo, sortPullRequests} from './pullRequests'
|
||||
import {ReleaseNotesOptions} from './releaseNotes'
|
||||
import {DiffInfo} from './commits'
|
||||
import {createOrSet, haveCommonElements, haveEveryElements} from './utils'
|
||||
@@ -47,13 +47,6 @@ export function buildChangelog(diffInfo: DiffInfo, prs: PullRequestInfo[], optio
|
||||
}
|
||||
}
|
||||
|
||||
// limit the PRs to the `max_pull_requests`
|
||||
const max_pull_requests = config.max_pull_requests || DefaultConfiguration.max_pull_requests
|
||||
if (prs.length > max_pull_requests) {
|
||||
core.info(`ℹ️ Retrieved ${prs.length} PRs, limit count to: ${max_pull_requests} (max_pull_requests).`)
|
||||
prs.length = Math.min(prs.length, max_pull_requests)
|
||||
}
|
||||
|
||||
// extract additional labels from the commit message
|
||||
const labelExtractors = validateTransformers(config.label_extractor)
|
||||
for (const extractor of labelExtractors) {
|
||||
@@ -400,14 +393,7 @@ function replaceReviewPlaceholders(template: string, parentKey: string, values:
|
||||
let transformed = template
|
||||
|
||||
// retrieve the keys from the CommentInfo object
|
||||
const comment: CommentInfo = {
|
||||
id: 0,
|
||||
htmlURL: '',
|
||||
submittedAt: undefined,
|
||||
author: '',
|
||||
body: ''
|
||||
}
|
||||
for (const childKey of Object.keys(comment)) {
|
||||
for (const childKey of Object.keys(EMPTY_COMMENT_INFO)) {
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
transformed = transformed.replaceAll(
|
||||
`\${{${parentKey}[${i}].${childKey}}}`,
|
||||
|
||||
Reference in New Issue
Block a user