Merge pull request #1031 from mikepenz/feature/overall_improvements
Overall improvements (and fix array placeholders)
This commit is contained in:
@@ -310,7 +310,7 @@ For advanced use cases additional settings can be provided to the action
|
||||
> **Note**: All input values are optional. It is only required to provide the `token` either via the input, or as `env` variable.
|
||||
|
||||
| **Input** | **Description** |
|
||||
|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `configurationJson` | Provide the configuration directly via the build `yml` file. Please note that `${{}}` has to be written as `#{{}}` within the `yml` file. |
|
||||
| `configuration` | Relative path, to the `configuration.json` file, providing additional configurations |
|
||||
| `outputFile` | Optional relative path to a file to store the resulting changelog in. |
|
||||
@@ -336,21 +336,52 @@ For advanced use cases additional settings can be provided to the action
|
||||
Table of supported placeholders allowed to be used in the `pr_template` configuration, which will be included in the release notes / changelog.
|
||||
|
||||
| **Placeholder** | **Description** |
|
||||
|-------------------|-------------------------------------------------------------------|
|
||||
| `${{NUMBER}}` | The number referencing this pull request. E.g. 13 |
|
||||
| `${{TITLE}}` | Specified title of the merged pull request |
|
||||
| `${{URL}}` | Url linking to the pull request on GitHub |
|
||||
|-------------------|----------------------------------------------------------------------------------------------------|
|
||||
| `${{NUMBER}}` | The number referencing this pull request. E.g. 13. |
|
||||
| `${{TITLE}}` | Specified title of the merged pull request. |
|
||||
| `${{URL}}` | Url linking to the pull request on GitHub. |
|
||||
| `${{STATUS}}` | Status of the PR. Usually always `merged`. Possibly `Open` if `includeOpen` is configured. |
|
||||
| `${{CREATED_AT}}` | The ISO time, the pull request was created at |
|
||||
| `${{MERGED_AT}}` | The ISO time, the pull request was merged at |
|
||||
| `${{MERGE_SHA}}` | The commit SHA, the pull request was merged with |
|
||||
| `${{AUTHOR}}` | Author creating and opening the pull request |
|
||||
| `${{LABELS}}` | The labels associated with this pull request, joined by `,` |
|
||||
| `${{MILESTONE}}` | Milestone this PR was part of, as assigned on GitHub |
|
||||
| `${{BODY}}` | Description/Body of the pull request as specified on GitHub |
|
||||
| `${{ASSIGNEES}}` | Login names of assigned GitHub users, joined by `,` |
|
||||
| `${{CREATED_AT}}` | The ISO time, the pull request was created at. |
|
||||
| `${{MERGED_AT}}` | The ISO time, the pull request was merged at. |
|
||||
| `${{MERGE_SHA}}` | The commit SHA, the pull request was merged with. |
|
||||
| `${{AUTHOR}}` | Author creating and opening the pull request. |
|
||||
| `${{LABELS}}` | The labels associated with this pull request, joined by `,`. |
|
||||
| `${{MILESTONE}}` | Milestone this PR was part of, as assigned on GitHub. |
|
||||
| `${{BODY}}` | Description/Body of the pull request as specified on GitHub. |
|
||||
| `${{ASSIGNEES}}` | Login names of assigned GitHub users, joined by `,`. |
|
||||
| `${{REVIEWERS}}` | GitHub Login names of specified reviewers, joined by `,`. Requires `fetchReviewers` to be enabled. |
|
||||
| `${{APPROVERS}}` | GitHub Login names of users who approved the PR, joined by `,` |
|
||||
| `${{APPROVERS}}` | GitHub Login names of users who approved the PR, joined by `,`. |
|
||||
|
||||
|
||||
<details><summary><b>Array Placeholders</b></summary>
|
||||
<p>
|
||||
|
||||
Table of special array placeholders allowed to be used in the `pr_template` configuration.
|
||||
|
||||
Array placeholders follow the following format: `(KEY)[(*/index)]` for example: `ASSIGNEES[*]` or `ASSIGNEES[0]`.
|
||||
When using `*` values are joined by `,`.
|
||||
|
||||
| **Placeholder** | **Description** |
|
||||
|---------------------|-------------------------------------------------------------------------------------|
|
||||
| `${{ASSIGNEES[*]}}` | Login names of assigned GitHub users. |
|
||||
| `${{REVIEWERS[*]}}` | GitHub Login names of specified reviewers. Requires `fetchReviewers` to be enabled. |
|
||||
| `${{APPROVERS[*]}}` | GitHub Login names of users who approved the PR. |
|
||||
|
||||
Additionally there is a special array placeholder `REVIEWS` which allows access to it's properties:
|
||||
`(KEY)[(*/index)].(property)` for example: `REVIEWS[*].author` or `REVIEWS[*].body`
|
||||
|
||||
| **Placeholder** | **Description** |
|
||||
|-------------------------------|--------------------------------------------|
|
||||
| `${{REVIEWS[*].author}}` | GitHub Login names of specified reviewers. |
|
||||
| `${{REVIEWS[*].body}}` | The body of the review. |
|
||||
| `${{REVIEWS[*].htmlURL}}` | The URL to the given review. |
|
||||
| `${{REVIEWS[*].submittedAt}}` | The date whent he review was submitted. |
|
||||
| `${{REVIEWS[*].state}}` | The state of the given review. |
|
||||
|
||||
</p>
|
||||
</details>
|
||||
|
||||
|
||||
|
||||
### Template placeholders
|
||||
|
||||
@@ -395,7 +426,7 @@ Table of descriptions for the `configuration.json` options to configure the resu
|
||||
| category.rules | An array of `rules` used to match PRs against. Any match will include the PR. (See `exhaustive` to change this) |
|
||||
| category.rules.pattern | A `regex` pattern to match the property value towards. Uses `RegExp.test("val")` |
|
||||
| category.rules.flags | Defines the regex flags specified for the pattern. Default: `gu`. |
|
||||
| category.rules.on_property | The PR property to match against. [Possible values](https://github.com/mikepenz/release-changelog-builder-action/blob/feature/category_rules/src/configuration.ts#L33-L43). |
|
||||
| category.rules.on_property | The PR property to match against. [Possible values](https://github.com/mikepenz/release-changelog-builder-action/blob/develop/src/configuration.ts#L33-L43). |
|
||||
| ignore_labels | An array of labels, to match pull request labels against. If any PR label overlaps, the pull request will be ignored from the changelog. This takes precedence over category labels |
|
||||
| sort | A `sort` specification, offering the ability to define sort order and property. |
|
||||
| sort.order | The sort order. Allowed values: `ASC`, `DESC` |
|
||||
@@ -455,7 +486,7 @@ Custom placeholders can be defined via the `configuration.json` as `custom_place
|
||||
This example will look for JIRA tickets in the EPIC project, and extract all of these tickets. The exciting part for that case is, that the ticket is PR bound, but can be used in the global TEMPLATE, but equally also in the PR template. This is unique for CUSTOM PLACEHOLDERS as standard palceholders do not offer this functionality.
|
||||
|
||||
| **Input** | **Description** |
|
||||
|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
|---------------------------------|------------------------------------------------------------------------------------------------------------------------------|
|
||||
| custom_placeholders | An array of `Placeholder` specifications, offering a flexible API to extract custom placeholders from existing placeholders. |
|
||||
| custom_placeholders.name | The name of the custom placeholder. Will be used within the template. |
|
||||
| custom_placeholders.source | The source PLACEHOLDER, requires to be one of the existing Template or PR Template placeholders. |
|
||||
|
||||
+37
-66
@@ -402,10 +402,19 @@ function run() {
|
||||
});
|
||||
if (configurationJson) {
|
||||
configJson = (0, utils_1.parseConfiguration)(configurationJson);
|
||||
if (configJson) {
|
||||
core.info(`ℹ️ Retreived configuration via 'configurationJson'.`);
|
||||
}
|
||||
}
|
||||
// read in the configuration from the file if possible
|
||||
const configurationFile = core.getInput('configuration');
|
||||
const configFile = (0, utils_1.resolveConfiguration)(repositoryPath, configurationFile);
|
||||
if (configFile) {
|
||||
core.info(`ℹ️ Retreived configuration via 'configuration' (via file).`);
|
||||
}
|
||||
if (!configurationFile && !configFile) {
|
||||
core.info(`ℹ️ No configuration provided. Using Defaults.`);
|
||||
}
|
||||
// merge configs, use default values from DefaultConfig on missing definition
|
||||
const configuration = (0, utils_1.mergeConfiguration)(configJson, configFile);
|
||||
// read in repository inputs
|
||||
@@ -616,42 +625,8 @@ class PullRequests {
|
||||
return sortPrs(openPrs);
|
||||
});
|
||||
}
|
||||
getReviewers(owner, repo, pr) {
|
||||
var _a, e_3, _b, _c;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const options = this.octokit.pulls.listReviews.endpoint.merge({
|
||||
owner,
|
||||
repo,
|
||||
pull_number: pr.number
|
||||
});
|
||||
try {
|
||||
for (var _d = true, _e = __asyncValues(this.octokit.paginate.iterator(options)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
|
||||
_c = _f.value;
|
||||
_d = false;
|
||||
try {
|
||||
const response = _c;
|
||||
const reviews = response.data;
|
||||
pr.approvedReviewers = reviews
|
||||
.filter(r => r.state === 'APPROVED')
|
||||
.map(r => { var _a; return (_a = r.user) === null || _a === void 0 ? void 0 : _a.login; })
|
||||
.filter(r => !!r);
|
||||
}
|
||||
finally {
|
||||
_d = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
||||
}
|
||||
finally { if (e_3) throw e_3.error; }
|
||||
}
|
||||
});
|
||||
}
|
||||
getReviews(owner, repo, pr) {
|
||||
var _a, e_4, _b, _c;
|
||||
var _a, e_3, _b, _c;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const options = this.octokit.pulls.listReviews.endpoint.merge({
|
||||
owner,
|
||||
@@ -677,12 +652,12 @@ class PullRequests {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
||||
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
||||
}
|
||||
finally { if (e_4) throw e_4.error; }
|
||||
finally { if (e_3) throw e_3.error; }
|
||||
}
|
||||
pr.reviews = prReviews;
|
||||
});
|
||||
@@ -1034,7 +1009,6 @@ class ReleaseNotes {
|
||||
});
|
||||
}
|
||||
getMergedPullRequests(octokit) {
|
||||
var _a, _b;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const { owner, repo, includeOpen, fetchReviewers, fetchReviews, configuration } = this.options;
|
||||
const diffInfo = yield this.getCommitHistory(octokit);
|
||||
@@ -1091,33 +1065,27 @@ class ReleaseNotes {
|
||||
return true;
|
||||
});
|
||||
if (baseBranches.length !== 0) {
|
||||
core.info(`ℹ️ Retrieved ${mergedPullRequests.length} PRs for ${owner}/${repo} filtered by the 'base_branches' configuration.`);
|
||||
core.info(`ℹ️ Retrieved ${finalPrs.length} PRs for ${owner}/${repo} filtered by the 'base_branches' configuration.`);
|
||||
}
|
||||
if (fetchReviewers) {
|
||||
core.info(`ℹ️ Fetching reviewers was enabled`);
|
||||
// update PR information with reviewers who approved
|
||||
for (const pr of finalPrs) {
|
||||
yield pullRequestsApi.getReviewers(owner, repo, pr);
|
||||
if (pr.approvedReviewers.length > 0) {
|
||||
core.info(`ℹ️ Retrieved ${pr.approvedReviewers.length} reviewer(s) for PR ${owner}/${repo}/#${pr.number}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
core.debug(`ℹ️ Fetching reviewers was disabled`);
|
||||
}
|
||||
if (fetchReviews) {
|
||||
core.info(`ℹ️ Fetching reviews was enabled`);
|
||||
// fetch reviewers only if enabled (requires an additional API request per PR)
|
||||
if (fetchReviews || fetchReviewers) {
|
||||
core.info(`ℹ️ Fetching reviews (or reviewers) was enabled`);
|
||||
// update PR information with reviewers who approved
|
||||
for (const pr of finalPrs) {
|
||||
yield pullRequestsApi.getReviews(owner, repo, pr);
|
||||
if ((((_a = pr.reviews) === null || _a === void 0 ? void 0 : _a.length) || 0) > 0) {
|
||||
core.info(`ℹ️ Retrieved ${((_b = pr.reviews) === null || _b === void 0 ? void 0 : _b.length) || 0} review(s) for PR ${owner}/${repo}/#${pr.number}`);
|
||||
const reviews = pr.reviews;
|
||||
if (reviews && ((reviews === null || reviews === void 0 ? void 0 : reviews.length) || 0) > 0) {
|
||||
core.info(`ℹ️ Retrieved ${reviews.length || 0} review(s) for PR ${owner}/${repo}/#${pr.number}`);
|
||||
// backwards compatiblity
|
||||
pr.approvedReviewers = reviews.filter(r => r.state === 'APPROVED').map(r => r.author);
|
||||
}
|
||||
else {
|
||||
core.debug(`No reviewer(s) for PR ${owner}/${repo}/#${pr.number}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
core.debug(`ℹ️ Fetching reviews was disabled`);
|
||||
core.debug(`ℹ️ Fetching reviews (or reviewers) was disabled`);
|
||||
}
|
||||
return [diffInfo, finalPrs];
|
||||
});
|
||||
@@ -1944,7 +1912,7 @@ function replaceEmptyTemplate(template, options) {
|
||||
}
|
||||
const placeholderMap = new Map();
|
||||
fillAdditionalPlaceholders(options, placeholderMap);
|
||||
return replacePlaceholders(template, new Map(), placeholderMap, placeholders, undefined, options.configuration);
|
||||
return replacePlaceholders(template, EMPTY_MAP, placeholderMap, placeholders, undefined, options.configuration);
|
||||
}
|
||||
exports.replaceEmptyTemplate = replaceEmptyTemplate;
|
||||
function fillAdditionalPlaceholders(options, placeholderMap /* placeholderKey and original value */) {
|
||||
@@ -2032,18 +2000,18 @@ function handlePlaceholder(template, key, value, placeholders /* placeholders to
|
||||
}
|
||||
function fillArrayPlaceholders(placeholderMap /* placeholderKey and original value */, key, values) {
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
placeholderMap.set(`\${{${key}[${i}]}}`, values[i]);
|
||||
placeholderMap.set(`${key}[${i}]`, values[i]);
|
||||
}
|
||||
placeholderMap.set(`\${{${key}[*]}}`, values.join(', '));
|
||||
placeholderMap.set(`${key}[*]`, values.join(', '));
|
||||
}
|
||||
function fillReviewPlaceholders(placeholderMap /* placeholderKey and original value */, parentKey, values) {
|
||||
var _a;
|
||||
// retrieve the keys from the CommentInfo object
|
||||
for (const childKey of Object.keys(pullRequests_1.EMPTY_COMMENT_INFO)) {
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
placeholderMap.set(`\${{${parentKey}[${i}].${childKey}}}`, ((_a = values[i][childKey]) === null || _a === void 0 ? void 0 : _a.toLocaleString('en')) || '');
|
||||
placeholderMap.set(`${parentKey}[${i}].${childKey}`, ((_a = values[i][childKey]) === null || _a === void 0 ? void 0 : _a.toLocaleString('en')) || '');
|
||||
}
|
||||
placeholderMap.set(`\${{${parentKey}[*].${childKey}}}`, values.map(value => { var _a; return ((_a = value[childKey]) === null || _a === void 0 ? void 0 : _a.toLocaleString('en')) || ''; }).join(', '));
|
||||
placeholderMap.set(`${parentKey}[*].${childKey}`, values.map(value => { var _a; return ((_a = value[childKey]) === null || _a === void 0 ? void 0 : _a.toLocaleString('en')) || ''; }).join(', '));
|
||||
}
|
||||
}
|
||||
function replacePrPlaceholders(template, placeholderPrMap /* map with all pr related custom placeholder values */, configuration) {
|
||||
@@ -2203,23 +2171,26 @@ exports.failOrError = failOrError;
|
||||
* Retrieves the configuration given the file path, if not found it will fallback to the `DefaultConfiguration`
|
||||
*/
|
||||
function resolveConfiguration(githubWorkspacePath, configurationFile) {
|
||||
let configuration = configuration_1.DefaultConfiguration;
|
||||
if (configurationFile) {
|
||||
const configurationPath = path.resolve(githubWorkspacePath, configurationFile);
|
||||
core.debug(`configurationPath = '${configurationPath}'`);
|
||||
const providedConfiguration = readConfiguration(configurationPath);
|
||||
if (providedConfiguration) {
|
||||
configuration = providedConfiguration;
|
||||
const configuration = providedConfiguration;
|
||||
core.info(`ℹ️ Configuration successfully loaded.`);
|
||||
if (core.isDebug()) {
|
||||
core.debug(`configuration = ${JSON.stringify(configuration)}`);
|
||||
}
|
||||
return configuration;
|
||||
}
|
||||
else {
|
||||
core.debug(`Configuration file could not be read.`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
core.info(`ℹ️ Configuration not provided. Using Defaults.`);
|
||||
core.debug(`Configuration file not provided.`);
|
||||
}
|
||||
return configuration;
|
||||
return undefined;
|
||||
}
|
||||
exports.resolveConfiguration = resolveConfiguration;
|
||||
/**
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+10
@@ -20,10 +20,20 @@ async function run(): Promise<void> {
|
||||
})
|
||||
if (configurationJson) {
|
||||
configJson = parseConfiguration(configurationJson)
|
||||
if (configJson) {
|
||||
core.info(`ℹ️ Retreived configuration via 'configurationJson'.`)
|
||||
}
|
||||
}
|
||||
// read in the configuration from the file if possible
|
||||
const configurationFile: string = core.getInput('configuration')
|
||||
const configFile = resolveConfiguration(repositoryPath, configurationFile)
|
||||
if (configFile) {
|
||||
core.info(`ℹ️ Retreived configuration via 'configuration' (via file).`)
|
||||
}
|
||||
|
||||
if (!configurationFile && !configFile) {
|
||||
core.info(`ℹ️ No configuration provided. Using Defaults.`)
|
||||
}
|
||||
|
||||
// merge configs, use default values from DefaultConfig on missing definition
|
||||
const configuration = mergeConfiguration(configJson, configFile)
|
||||
|
||||
@@ -47,8 +47,6 @@ type PullData = RestEndpointMethodTypes['pulls']['get']['response']['data']
|
||||
|
||||
type PullsListData = RestEndpointMethodTypes['pulls']['list']['response']['data']
|
||||
|
||||
type PullReviewData = RestEndpointMethodTypes['pulls']['listReviews']['response']['data']
|
||||
|
||||
type PullReviewsData = RestEndpointMethodTypes['pulls']['listReviews']['response']['data']
|
||||
|
||||
export class PullRequests {
|
||||
@@ -143,22 +141,6 @@ export class PullRequests {
|
||||
return sortPrs(openPrs)
|
||||
}
|
||||
|
||||
async getReviewers(owner: string, repo: string, pr: PullRequestInfo): Promise<void> {
|
||||
const options = this.octokit.pulls.listReviews.endpoint.merge({
|
||||
owner,
|
||||
repo,
|
||||
pull_number: pr.number
|
||||
})
|
||||
|
||||
for await (const response of this.octokit.paginate.iterator(options)) {
|
||||
const reviews: PullReviewData = response.data as PullReviewData
|
||||
pr.approvedReviewers = reviews
|
||||
.filter(r => r.state === 'APPROVED')
|
||||
.map(r => r.user?.login)
|
||||
.filter(r => !!r) as string[]
|
||||
}
|
||||
}
|
||||
|
||||
async getReviews(owner: string, repo: string, pr: PullRequestInfo): Promise<void> {
|
||||
const options = this.octokit.pulls.listReviews.endpoint.merge({
|
||||
owner,
|
||||
|
||||
+14
-19
@@ -165,33 +165,28 @@ export class ReleaseNotes {
|
||||
})
|
||||
|
||||
if (baseBranches.length !== 0) {
|
||||
core.info(`ℹ️ Retrieved ${mergedPullRequests.length} PRs for ${owner}/${repo} filtered by the 'base_branches' configuration.`)
|
||||
core.info(`ℹ️ Retrieved ${finalPrs.length} PRs for ${owner}/${repo} filtered by the 'base_branches' configuration.`)
|
||||
}
|
||||
|
||||
if (fetchReviewers) {
|
||||
core.info(`ℹ️ Fetching reviewers was enabled`)
|
||||
// update PR information with reviewers who approved
|
||||
for (const pr of finalPrs) {
|
||||
await pullRequestsApi.getReviewers(owner, repo, pr)
|
||||
if (pr.approvedReviewers.length > 0) {
|
||||
core.info(`ℹ️ Retrieved ${pr.approvedReviewers.length} reviewer(s) for PR ${owner}/${repo}/#${pr.number}`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
core.debug(`ℹ️ Fetching reviewers was disabled`)
|
||||
}
|
||||
|
||||
if (fetchReviews) {
|
||||
core.info(`ℹ️ Fetching reviews was enabled`)
|
||||
// fetch reviewers only if enabled (requires an additional API request per PR)
|
||||
if (fetchReviews || fetchReviewers) {
|
||||
core.info(`ℹ️ Fetching reviews (or reviewers) was enabled`)
|
||||
// update PR information with reviewers who approved
|
||||
for (const pr of finalPrs) {
|
||||
await pullRequestsApi.getReviews(owner, repo, pr)
|
||||
if ((pr.reviews?.length || 0) > 0) {
|
||||
core.info(`ℹ️ Retrieved ${pr.reviews?.length || 0} review(s) for PR ${owner}/${repo}/#${pr.number}`)
|
||||
|
||||
const reviews = pr.reviews
|
||||
if (reviews && (reviews?.length || 0) > 0) {
|
||||
core.info(`ℹ️ Retrieved ${reviews.length || 0} review(s) for PR ${owner}/${repo}/#${pr.number}`)
|
||||
|
||||
// backwards compatiblity
|
||||
pr.approvedReviewers = reviews.filter(r => r.state === 'APPROVED').map(r => r.author)
|
||||
} else {
|
||||
core.debug(`No reviewer(s) for PR ${owner}/${repo}/#${pr.number}`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
core.debug(`ℹ️ Fetching reviews was disabled`)
|
||||
core.debug(`ℹ️ Fetching reviews (or reviewers) was disabled`)
|
||||
}
|
||||
|
||||
return [diffInfo, finalPrs]
|
||||
|
||||
+5
-5
@@ -269,7 +269,7 @@ export function replaceEmptyTemplate(template: string, options: ReleaseNotesOpti
|
||||
}
|
||||
const placeholderMap = new Map<string, string>()
|
||||
fillAdditionalPlaceholders(options, placeholderMap)
|
||||
return replacePlaceholders(template, new Map<string, string>(), placeholderMap, placeholders, undefined, options.configuration)
|
||||
return replacePlaceholders(template, EMPTY_MAP, placeholderMap, placeholders, undefined, options.configuration)
|
||||
}
|
||||
|
||||
function fillAdditionalPlaceholders(
|
||||
@@ -394,9 +394,9 @@ function fillArrayPlaceholders(
|
||||
values: string[]
|
||||
): void {
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
placeholderMap.set(`\${{${key}[${i}]}}`, values[i])
|
||||
placeholderMap.set(`${key}[${i}]`, values[i])
|
||||
}
|
||||
placeholderMap.set(`\${{${key}[*]}}`, values.join(', '))
|
||||
placeholderMap.set(`${key}[*]`, values.join(', '))
|
||||
}
|
||||
|
||||
function fillReviewPlaceholders(
|
||||
@@ -407,10 +407,10 @@ function fillReviewPlaceholders(
|
||||
// retrieve the keys from the CommentInfo object
|
||||
for (const childKey of Object.keys(EMPTY_COMMENT_INFO)) {
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
placeholderMap.set(`\${{${parentKey}[${i}].${childKey}}}`, values[i][childKey as keyof CommentInfo]?.toLocaleString('en') || '')
|
||||
placeholderMap.set(`${parentKey}[${i}].${childKey}`, values[i][childKey as keyof CommentInfo]?.toLocaleString('en') || '')
|
||||
}
|
||||
placeholderMap.set(
|
||||
`\${{${parentKey}[*].${childKey}}}`,
|
||||
`${parentKey}[*].${childKey}`,
|
||||
values.map(value => value[childKey as keyof CommentInfo]?.toLocaleString('en') || '').join(', ')
|
||||
)
|
||||
}
|
||||
|
||||
+7
-5
@@ -35,23 +35,25 @@ export function failOrError(message: string | Error, failOnError: boolean): void
|
||||
/**
|
||||
* Retrieves the configuration given the file path, if not found it will fallback to the `DefaultConfiguration`
|
||||
*/
|
||||
export function resolveConfiguration(githubWorkspacePath: string, configurationFile: string): Configuration {
|
||||
let configuration = DefaultConfiguration
|
||||
export function resolveConfiguration(githubWorkspacePath: string, configurationFile: string): Configuration | undefined {
|
||||
if (configurationFile) {
|
||||
const configurationPath = path.resolve(githubWorkspacePath, configurationFile)
|
||||
core.debug(`configurationPath = '${configurationPath}'`)
|
||||
const providedConfiguration = readConfiguration(configurationPath)
|
||||
if (providedConfiguration) {
|
||||
configuration = providedConfiguration
|
||||
const configuration = providedConfiguration
|
||||
core.info(`ℹ️ Configuration successfully loaded.`)
|
||||
if (core.isDebug()) {
|
||||
core.debug(`configuration = ${JSON.stringify(configuration)}`)
|
||||
}
|
||||
return configuration
|
||||
} else {
|
||||
core.debug(`Configuration file could not be read.`)
|
||||
}
|
||||
} else {
|
||||
core.info(`ℹ️ Configuration not provided. Using Defaults.`)
|
||||
core.debug(`Configuration file not provided.`)
|
||||
}
|
||||
return configuration
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user