- use || instead of ??
This commit is contained in:
+4
-11
@@ -27,15 +27,8 @@ async function run(): Promise<void> {
|
||||
|
||||
// read in repository inputs
|
||||
const token = core.getInput('token')
|
||||
|
||||
core.info(`owner: ${core.getInput('owner')}`)
|
||||
core.info(`owner2: ${github.context.repo.owner}`)
|
||||
core.info(`owner3: ${ core.getInput('repository')}`)
|
||||
core.info(`owner4: ${ core.getInput('repository')[0]}`)
|
||||
core.info(`owner5: ${ core.getInput('owner') ?? github.context.repo.owner ?? core.getInput('repository').split('/')[0]}`)
|
||||
|
||||
const owner = core.getInput('owner') ?? github.context.repo.owner ?? core.getInput('repository').split('/')[0]
|
||||
const repo = core.getInput('repo') ?? github.context.repo.repo ?? core.getInput('repository').split('/')[1]
|
||||
const owner = core.getInput('owner') || github.context.repo.owner
|
||||
const repo = core.getInput('repo') || github.context.repo.repo
|
||||
// read in from, to tag inputs
|
||||
const fromTag = core.getInput('fromTag')
|
||||
let toTag = core.getInput('toTag')
|
||||
@@ -99,8 +92,8 @@ async function run(): Promise<void> {
|
||||
|
||||
core.setOutput(
|
||||
'changelog',
|
||||
(await releaseNotes.pull(token)) ??
|
||||
configuration.empty_template ??
|
||||
(await releaseNotes.pull(token)) ||
|
||||
configuration.empty_template ||
|
||||
DefaultConfiguration.empty_template
|
||||
)
|
||||
} catch (error) {
|
||||
|
||||
+4
-4
@@ -44,7 +44,7 @@ export class ReleaseNotes {
|
||||
repo,
|
||||
toTag,
|
||||
ignorePreReleases,
|
||||
configuration.max_tags_to_fetch ??
|
||||
configuration.max_tags_to_fetch ||
|
||||
DefaultConfiguration.max_tags_to_fetch
|
||||
)
|
||||
if (previousTag == null) {
|
||||
@@ -116,7 +116,7 @@ export class ReleaseNotes {
|
||||
const toDate = lastCommit.date
|
||||
|
||||
const maxDays =
|
||||
configuration.max_back_track_time_days ??
|
||||
configuration.max_back_track_time_days ||
|
||||
DefaultConfiguration.max_back_track_time_days
|
||||
const maxFromDate = toDate.clone().subtract(maxDays, 'days')
|
||||
if (maxFromDate.isAfter(fromDate)) {
|
||||
@@ -134,7 +134,7 @@ export class ReleaseNotes {
|
||||
repo,
|
||||
fromDate,
|
||||
toDate,
|
||||
configuration.max_pull_requests ?? DefaultConfiguration.max_pull_requests
|
||||
configuration.max_pull_requests || DefaultConfiguration.max_pull_requests
|
||||
)
|
||||
|
||||
core.info(
|
||||
@@ -143,7 +143,7 @@ export class ReleaseNotes {
|
||||
|
||||
const prCommits = pullRequestsApi.filterCommits(
|
||||
commits,
|
||||
configuration.exclude_merge_branches ??
|
||||
configuration.exclude_merge_branches ||
|
||||
DefaultConfiguration.exclude_merge_branches
|
||||
)
|
||||
|
||||
|
||||
+8
-8
@@ -12,7 +12,7 @@ export function buildChangelog(
|
||||
config: Configuration
|
||||
): string {
|
||||
// sort to target order
|
||||
const sort = config.sort ?? DefaultConfiguration.sort
|
||||
const sort = config.sort || DefaultConfiguration.sort
|
||||
const sortAsc = sort.toUpperCase() === 'ASC'
|
||||
prs = sortPullRequests(prs, sortAsc)
|
||||
core.info(`ℹ️ Sorted all pull requests ascending: ${sort}`)
|
||||
@@ -41,7 +41,7 @@ export function buildChangelog(
|
||||
|
||||
// bring PRs into the order of categories
|
||||
const categorized = new Map<Category, string[]>()
|
||||
const categories = config.categories ?? DefaultConfiguration.categories
|
||||
const categories = config.categories || DefaultConfiguration.categories
|
||||
for (const category of categories) {
|
||||
categorized.set(category, [])
|
||||
}
|
||||
@@ -89,7 +89,7 @@ export function buildChangelog(
|
||||
)
|
||||
|
||||
// fill template
|
||||
let transformedChangelog = config.template ?? DefaultConfiguration.template
|
||||
let transformedChangelog = config.template || DefaultConfiguration.template
|
||||
transformedChangelog = transformedChangelog.replace(
|
||||
'${{CHANGELOG}}',
|
||||
changelog
|
||||
@@ -113,16 +113,16 @@ function fillTemplate(pr: PullRequestInfo, template: string): string {
|
||||
transformed = transformed.replace('${{URL}}', pr.htmlURL)
|
||||
transformed = transformed.replace('${{MERGED_AT}}', pr.mergedAt.toISOString())
|
||||
transformed = transformed.replace('${{AUTHOR}}', pr.author)
|
||||
transformed = transformed.replace('${{LABELS}}', pr.labels?.join(', ') ?? '')
|
||||
transformed = transformed.replace('${{MILESTONE}}', pr.milestone ?? '')
|
||||
transformed = transformed.replace('${{LABELS}}', pr.labels?.join(', ') || '')
|
||||
transformed = transformed.replace('${{MILESTONE}}', pr.milestone || '')
|
||||
transformed = transformed.replace('${{BODY}}', pr.body)
|
||||
transformed = transformed.replace(
|
||||
'${{ASSIGNEES}}',
|
||||
pr.assignees?.join(', ') ?? ''
|
||||
pr.assignees?.join(', ') || ''
|
||||
)
|
||||
transformed = transformed.replace(
|
||||
'${{REVIEWERS}}',
|
||||
pr.requestedReviewers?.join(', ') ?? ''
|
||||
pr.requestedReviewers?.join(', ') || ''
|
||||
)
|
||||
return transformed
|
||||
}
|
||||
@@ -142,7 +142,7 @@ function validateTransfomers(
|
||||
specifiedTransformers: Transformer[]
|
||||
): RegexTransformer[] {
|
||||
const transformers =
|
||||
specifiedTransformers ?? DefaultConfiguration.transformers
|
||||
specifiedTransformers || DefaultConfiguration.transformers
|
||||
return transformers
|
||||
.map(transformer => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user