- introduce proper configuration for fetchReviews

- drop no longer needed limiting of PRs
- retrieve state from PR review comment
This commit is contained in:
Mike Penz
2022-12-09 13:29:06 +00:00
committed by GitHub
parent 2fe056f840
commit 24f4e30f9f
12 changed files with 81 additions and 40 deletions
+1
View File
@@ -523,6 +523,7 @@ it('Test custom changelog builder', async () => {
false, // ignorePrePrelease false, // ignorePrePrelease
true, // enable to fetch reviewers true, // enable to fetch reviewers
false, // enable to fetch release information false, // enable to fetch release information
false, // enable to fetch reviews
false, // commitMode false, // commitMode
configuration // configuration configuration // configuration
) )
+10
View File
@@ -20,6 +20,7 @@ it('Should have empty changelog (tags)', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -40,6 +41,7 @@ it('Should match generated changelog (tags)', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -65,6 +67,7 @@ it('Should match generated changelog (refs)', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -98,6 +101,7 @@ it('Should match generated changelog and replace all occurrences (refs)', async
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -133,6 +137,7 @@ it('Should match ordered ASC', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -153,6 +158,7 @@ it('Should match ordered DESC', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -173,6 +179,7 @@ it('Should match ordered by title ASC', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -195,6 +202,7 @@ it('Should match ordered by title DESC', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -217,6 +225,7 @@ it('Should ignore PRs not merged into develop branch', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -237,6 +246,7 @@ it('Should ignore PRs not merged into main branch', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
+14
View File
@@ -18,6 +18,7 @@ it('Should match generated changelog (unspecified fromTag)', async () => {
false, false,
false, // enable to fetch reviewers false, // enable to fetch reviewers
false, // enable to fetch tag release information false, // enable to fetch tag release information
false, // enable to fetch reviews
false, false,
configuration configuration
) )
@@ -47,6 +48,7 @@ it('Should match generated changelog (unspecified tags)', async () => {
false, false,
false, // enable to fetch reviewers false, // enable to fetch reviewers
false, // enable to fetch tag release information false, // enable to fetch tag release information
false, // enable to fetch reviews
false, false,
configuration configuration
) )
@@ -71,6 +73,7 @@ it('Should use empty placeholder', async () => {
false, false,
false, // enable to fetch reviewers false, // enable to fetch reviewers
false, // enable to fetch tag release information false, // enable to fetch tag release information
false, // enable to fetch reviews
false, false,
configuration configuration
) )
@@ -95,6 +98,7 @@ it('Should fill empty placeholders', async () => {
false, false,
false, // enable to fetch reviewers false, // enable to fetch reviewers
false, // enable to fetch tag release information false, // enable to fetch tag release information
false, // enable to fetch reviews
false, false,
configuration configuration
) )
@@ -121,6 +125,7 @@ it('Should fill `template` placeholders', async () => {
false, false,
false, // enable to fetch reviewers false, // enable to fetch reviewers
false, // enable to fetch tag release information false, // enable to fetch tag release information
false, // enable to fetch reviews
false, false,
configuration configuration
) )
@@ -147,6 +152,7 @@ it('Should fill `template` placeholders, ignore', async () => {
false, false,
false, // enable to fetch reviewers false, // enable to fetch reviewers
false, // enable to fetch tag release information false, // enable to fetch tag release information
false, // enable to fetch reviews
false, false,
configuration configuration
) )
@@ -173,6 +179,7 @@ it('Uncategorized category', async () => {
false, false,
false, // enable to fetch reviewers false, // enable to fetch reviewers
false, // enable to fetch tag release information false, // enable to fetch tag release information
false, // enable to fetch reviews
false, false,
configuration configuration
) )
@@ -199,6 +206,7 @@ it('Verify commit based changelog', async () => {
false, false,
false, // enable to fetch reviewers false, // enable to fetch reviewers
false, // enable to fetch tag release information false, // enable to fetch tag release information
false, // enable to fetch reviews
true, true,
configuration configuration
) )
@@ -225,6 +233,7 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
false, false,
false, // enable to fetch reviewers false, // enable to fetch reviewers
false, // enable to fetch tag release information false, // enable to fetch tag release information
false, // enable to fetch reviews
true, true,
configuration configuration
) )
@@ -251,6 +260,7 @@ it('Verify default inclusion of open PRs', async () => {
false, // ignorePrePrelease false, // ignorePrePrelease
false, // enable to fetch reviewers false, // enable to fetch reviewers
false, // enable to fetch tag release information false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // commitMode false, // commitMode
configuration // configuration configuration // configuration
) )
@@ -277,6 +287,7 @@ it('Verify custom categorisation of open PRs', async () => {
false, // ignorePrePrelease false, // ignorePrePrelease
false, // enable to fetch reviewers false, // enable to fetch reviewers
false, // enable to fetch tag release information false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // commitMode false, // commitMode
configuration // configuration configuration // configuration
) )
@@ -303,6 +314,7 @@ it('Verify reviewers who approved are fetched and also release information', asy
false, // ignorePrePrelease false, // ignorePrePrelease
true, // enable to fetch reviewers true, // enable to fetch reviewers
true, // enable to fetch tag release information true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // commitMode false, // commitMode
configuration // configuration configuration // configuration
) )
@@ -330,6 +342,7 @@ it('Fetch release information', async () => {
false, // ignorePrePrelease false, // ignorePrePrelease
false, // enable to fetch reviewers false, // enable to fetch reviewers
true, // enable to fetch tag release information true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // commitMode false, // commitMode
configuration // configuration configuration // configuration
) )
@@ -355,6 +368,7 @@ it('Fetch release information for non existing tag / release', async () => {
false, // ignorePrePrelease false, // ignorePrePrelease
false, // enable to fetch reviewers false, // enable to fetch reviewers
true, // enable to fetch tag release information true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // commitMode false, // commitMode
configuration // configuration configuration // configuration
) )
+14
View File
@@ -140,6 +140,7 @@ it('Extract label from title, combined regex', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -169,6 +170,7 @@ it('Extract label from title and body, combined regex', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -201,6 +203,7 @@ it('Extract label from title, split regex', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -233,6 +236,7 @@ it('Extract label from title, match', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -260,6 +264,7 @@ it('Extract label from title, match multiple', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -288,6 +293,7 @@ it('Extract label from title, match multiple, custon non matching label', async
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration configuration
}) })
@@ -403,6 +409,7 @@ it('Match multiple labels exhaustive for category', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration: customConfig configuration: customConfig
}) })
@@ -429,6 +436,7 @@ it('Deduplicate duplicated PRs', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration: customConfig configuration: customConfig
}) })
@@ -456,6 +464,7 @@ it('Deduplicate duplicated PRs DESC', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration: customConfig configuration: customConfig
}) })
@@ -488,6 +497,7 @@ it('Use empty_content for empty category', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration: customConfig configuration: customConfig
}) })
@@ -511,6 +521,7 @@ it('Commit SHA-1 in commitMode', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: true, commitMode: true,
configuration: customConfig configuration: customConfig
}) })
@@ -531,6 +542,7 @@ it('Release Diff', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: true, fetchReleaseInformation: true,
fetchReviews: false,
commitMode: true, commitMode: true,
configuration: customConfig configuration: customConfig
}) })
@@ -570,6 +582,7 @@ it('Use exclude labels to not include a PR within a category.', async () => {
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration: customConfig configuration: customConfig
}) })
@@ -628,6 +641,7 @@ it('Extract custom placeholder from PR body and replace in global template', asy
failOnError: false, failOnError: false,
fetchReviewers: false, fetchReviewers: false,
fetchReleaseInformation: false, fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false, commitMode: false,
configuration: customConfig configuration: customConfig
}) })
+3
View File
@@ -34,6 +34,9 @@ inputs:
fetchReleaseInformation: fetchReleaseInformation:
description: 'Will enable fetching release information for the tags. E.g. creation date' description: 'Will enable fetching release information for the tags. E.g. creation date'
default: "false" default: "false"
fetchReviews:
description: 'Will enable fetching the reviews (comments) attached to the PR'
default: "false"
commitMode: commitMode:
description: 'Enables a `light` commit based mode. This mode generates changelogs based on the commits. Please note that this is not officially supported, and lacks a lot of features only possible with PRs.' description: 'Enables a `light` commit based mode. This mode generates changelogs based on the commits. Please note that this is not officially supported, and lacks a lot of features only possible with PRs.'
default: "false" default: "false"
Generated Vendored
+18 -20
View File
@@ -420,8 +420,9 @@ function run() {
const failOnError = core.getInput('failOnError') === 'true'; const failOnError = core.getInput('failOnError') === 'true';
const fetchReviewers = core.getInput('fetchReviewers') === 'true'; const fetchReviewers = core.getInput('fetchReviewers') === 'true';
const fetchReleaseInformation = core.getInput('fetchReleaseInformation') === 'true'; const fetchReleaseInformation = core.getInput('fetchReleaseInformation') === 'true';
const fetchReviews = core.getInput('fetchReviews') === 'true';
const commitMode = core.getInput('commitMode') === 'true'; const commitMode = core.getInput('commitMode') === 'true';
const result = yield new releaseNotesBuilder_1.ReleaseNotesBuilder(baseUrl, token, repositoryPath, owner, repo, fromTag, toTag, includeOpen, failOnError, ignorePreReleases, fetchReviewers, fetchReleaseInformation, commitMode, configuration).build(); const result = yield new releaseNotesBuilder_1.ReleaseNotesBuilder(baseUrl, token, repositoryPath, owner, repo, fromTag, toTag, includeOpen, failOnError, ignorePreReleases, fetchReviewers, fetchReleaseInformation, fetchReviews, commitMode, configuration).build();
core.setOutput('changelog', result); core.setOutput('changelog', result);
// write the result in changelog to file if possible // write the result in changelog to file if possible
const outputFile = core.getInput('outputFile'); const outputFile = core.getInput('outputFile');
@@ -488,9 +489,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.compare = exports.sortPullRequests = exports.PullRequests = void 0; exports.compare = exports.sortPullRequests = exports.PullRequests = exports.EMPTY_COMMENT_INFO = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const moment_1 = __importDefault(__nccwpck_require__(9623)); const moment_1 = __importDefault(__nccwpck_require__(9623));
exports.EMPTY_COMMENT_INFO = {
id: 0,
htmlURL: '',
submittedAt: undefined,
author: '',
body: '',
state: undefined
};
class PullRequests { class PullRequests {
constructor(octokit) { constructor(octokit) {
this.octokit = octokit; this.octokit = octokit;
@@ -762,7 +771,8 @@ const mapComment = (comment) => {
htmlURL: comment.html_url, htmlURL: comment.html_url,
submittedAt: comment.submitted_at ? (0, moment_1.default)(comment.submitted_at) : undefined, submittedAt: comment.submitted_at ? (0, moment_1.default)(comment.submitted_at) : undefined,
author: ((_a = comment.user) === null || _a === void 0 ? void 0 : _a.login) || '', author: ((_a = comment.user) === null || _a === void 0 ? void 0 : _a.login) || '',
body: comment.body body: comment.body,
state: comment.state
}); });
}; };
@@ -882,8 +892,7 @@ class ReleaseNotes {
getMergedPullRequests(octokit) { getMergedPullRequests(octokit) {
var _a, _b; var _a, _b;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const { owner, repo, includeOpen, fetchReviewers, configuration } = this.options; const { owner, repo, includeOpen, fetchReviewers, fetchReviews, configuration } = this.options;
const fetchReviews = true; // TEMPORARY!!
const diffInfo = yield this.getCommitHistory(octokit); const diffInfo = yield this.getCommitHistory(octokit);
const commits = diffInfo.commitInfo; const commits = diffInfo.commitInfo;
if (commits.length === 0) { if (commits.length === 0) {
@@ -1055,7 +1064,7 @@ const tags_1 = __nccwpck_require__(7532);
const utils_1 = __nccwpck_require__(918); const utils_1 = __nccwpck_require__(918);
const https_proxy_agent_1 = __nccwpck_require__(7219); const https_proxy_agent_1 = __nccwpck_require__(7219);
class ReleaseNotesBuilder { class ReleaseNotesBuilder {
constructor(baseUrl, token, repositoryPath, owner, repo, fromTag, toTag, includeOpen = false, failOnError, ignorePreReleases, fetchReviewers = false, fetchReleaseInformation = false, commitMode, configuration) { constructor(baseUrl, token, repositoryPath, owner, repo, fromTag, toTag, includeOpen = false, failOnError, ignorePreReleases, fetchReviewers = false, fetchReleaseInformation = false, fetchReviews = false, commitMode, configuration) {
this.baseUrl = baseUrl; this.baseUrl = baseUrl;
this.token = token; this.token = token;
this.repositoryPath = repositoryPath; this.repositoryPath = repositoryPath;
@@ -1068,6 +1077,7 @@ class ReleaseNotesBuilder {
this.ignorePreReleases = ignorePreReleases; this.ignorePreReleases = ignorePreReleases;
this.fetchReviewers = fetchReviewers; this.fetchReviewers = fetchReviewers;
this.fetchReleaseInformation = fetchReleaseInformation; this.fetchReleaseInformation = fetchReleaseInformation;
this.fetchReviews = fetchReviews;
this.commitMode = commitMode; this.commitMode = commitMode;
this.configuration = configuration; this.configuration = configuration;
} }
@@ -1150,6 +1160,7 @@ class ReleaseNotesBuilder {
failOnError: this.failOnError, failOnError: this.failOnError,
fetchReviewers: this.fetchReviewers, fetchReviewers: this.fetchReviewers,
fetchReleaseInformation: this.fetchReleaseInformation, fetchReleaseInformation: this.fetchReleaseInformation,
fetchReviews: this.fetchReviews,
commitMode: this.commitMode, commitMode: this.commitMode,
configuration: this.configuration configuration: this.configuration
}; };
@@ -1593,12 +1604,6 @@ function buildChangelog(diffInfo, prs, options) {
core.warning(`⚠️ Configured \`duplicate_filter\` invalid.`); core.warning(`⚠️ Configured \`duplicate_filter\` invalid.`);
} }
} }
// limit the PRs to the `max_pull_requests`
const max_pull_requests = config.max_pull_requests || configuration_1.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 // extract additional labels from the commit message
const labelExtractors = validateTransformers(config.label_extractor); const labelExtractors = validateTransformers(config.label_extractor);
for (const extractor of labelExtractors) { for (const extractor of labelExtractors) {
@@ -1875,14 +1880,7 @@ function replaceReviewPlaceholders(template, parentKey, values) {
var _a; var _a;
let transformed = template; let transformed = template;
// retrieve the keys from the CommentInfo object // retrieve the keys from the CommentInfo object
const comment = { for (const childKey of Object.keys(pullRequests_1.EMPTY_COMMENT_INFO)) {
id: 0,
htmlURL: '',
submittedAt: undefined,
author: '',
body: ''
};
for (const childKey of Object.keys(comment)) {
for (let i = 0; i < values.length; i++) { for (let i = 0; i < values.length; i++) {
transformed = transformed.replaceAll(`\${{${parentKey}[${i}].${childKey}}}`, ((_a = values[i][childKey]) === null || _a === void 0 ? void 0 : _a.toLocaleString('en')) || ''); transformed = transformed.replaceAll(`\${{${parentKey}[${i}].${childKey}}}`, ((_a = values[i][childKey]) === null || _a === void 0 ? void 0 : _a.toLocaleString('en')) || '');
} }
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+2
View File
@@ -40,6 +40,7 @@ async function run(): Promise<void> {
const failOnError = core.getInput('failOnError') === 'true' const failOnError = core.getInput('failOnError') === 'true'
const fetchReviewers = core.getInput('fetchReviewers') === 'true' const fetchReviewers = core.getInput('fetchReviewers') === 'true'
const fetchReleaseInformation = core.getInput('fetchReleaseInformation') === 'true' const fetchReleaseInformation = core.getInput('fetchReleaseInformation') === 'true'
const fetchReviews = core.getInput('fetchReviews') === 'true'
const commitMode = core.getInput('commitMode') === 'true' const commitMode = core.getInput('commitMode') === 'true'
const result = await new ReleaseNotesBuilder( const result = await new ReleaseNotesBuilder(
@@ -55,6 +56,7 @@ async function run(): Promise<void> {
ignorePreReleases, ignorePreReleases,
fetchReviewers, fetchReviewers,
fetchReleaseInformation, fetchReleaseInformation,
fetchReviews,
commitMode, commitMode,
configuration configuration
).build() ).build()
+12 -1
View File
@@ -31,6 +31,16 @@ export interface CommentInfo {
submittedAt: moment.Moment | undefined submittedAt: moment.Moment | undefined
author: string author: string
body: 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'] type PullData = RestEndpointMethodTypes['pulls']['get']['response']['data']
@@ -251,5 +261,6 @@ const mapComment = (comment: Unpacked<PullReviewsData>): CommentInfo => ({
htmlURL: comment.html_url, htmlURL: comment.html_url,
submittedAt: comment.submitted_at ? moment(comment.submitted_at) : undefined, submittedAt: comment.submitted_at ? moment(comment.submitted_at) : undefined,
author: comment.user?.login || '', author: comment.user?.login || '',
body: comment.body body: comment.body,
state: comment.state
}) })
+2 -2
View File
@@ -16,6 +16,7 @@ export interface ReleaseNotesOptions {
failOnError: boolean // defines if we should fail the action in case of an error 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 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 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 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` configuration: Configuration // the configuration as defined in `configuration.ts`
} }
@@ -94,8 +95,7 @@ export class ReleaseNotes {
} }
private async getMergedPullRequests(octokit: Octokit): Promise<[DiffInfo, PullRequestInfo[]]> { private async getMergedPullRequests(octokit: Octokit): Promise<[DiffInfo, PullRequestInfo[]]> {
const {owner, repo, includeOpen, fetchReviewers, configuration} = this.options const {owner, repo, includeOpen, fetchReviewers, fetchReviews, configuration} = this.options
const fetchReviews = true // TEMPORARY!!
const diffInfo = await this.getCommitHistory(octokit) const diffInfo = await this.getCommitHistory(octokit)
const commits = diffInfo.commitInfo const commits = diffInfo.commitInfo
+2
View File
@@ -20,6 +20,7 @@ export class ReleaseNotesBuilder {
private ignorePreReleases: boolean, private ignorePreReleases: boolean,
private fetchReviewers: boolean = false, private fetchReviewers: boolean = false,
private fetchReleaseInformation: boolean = false, private fetchReleaseInformation: boolean = false,
private fetchReviews: boolean = false,
private commitMode: boolean, private commitMode: boolean,
private configuration: Configuration private configuration: Configuration
) {} ) {}
@@ -117,6 +118,7 @@ export class ReleaseNotesBuilder {
failOnError: this.failOnError, failOnError: this.failOnError,
fetchReviewers: this.fetchReviewers, fetchReviewers: this.fetchReviewers,
fetchReleaseInformation: this.fetchReleaseInformation, fetchReleaseInformation: this.fetchReleaseInformation,
fetchReviews: this.fetchReviews,
commitMode: this.commitMode, commitMode: this.commitMode,
configuration: this.configuration configuration: this.configuration
} }
+2 -16
View File
@@ -1,6 +1,6 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import {Category, DefaultConfiguration, Extractor, Placeholder, Transformer} from './configuration' 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 {ReleaseNotesOptions} from './releaseNotes'
import {DiffInfo} from './commits' import {DiffInfo} from './commits'
import {createOrSet, haveCommonElements, haveEveryElements} from './utils' 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 // extract additional labels from the commit message
const labelExtractors = validateTransformers(config.label_extractor) const labelExtractors = validateTransformers(config.label_extractor)
for (const extractor of labelExtractors) { for (const extractor of labelExtractors) {
@@ -400,14 +393,7 @@ function replaceReviewPlaceholders(template: string, parentKey: string, values:
let transformed = template let transformed = template
// retrieve the keys from the CommentInfo object // retrieve the keys from the CommentInfo object
const comment: CommentInfo = { for (const childKey of Object.keys(EMPTY_COMMENT_INFO)) {
id: 0,
htmlURL: '',
submittedAt: undefined,
author: '',
body: ''
}
for (const childKey of Object.keys(comment)) {
for (let i = 0; i < values.length; i++) { for (let i = 0; i < values.length; i++) {
transformed = transformed.replaceAll( transformed = transformed.replaceAll(
`\${{${parentKey}[${i}].${childKey}}}`, `\${{${parentKey}[${i}].${childKey}}}`,