- introduce better handling of cases in which invalid references are provided, return an empty changelog and send out error

This commit is contained in:
Mike Penz
2020-10-17 17:38:08 +02:00
parent 5ce9cb0351
commit 619d3f460e
3 changed files with 47 additions and 6 deletions
+10 -6
View File
@@ -1,5 +1,5 @@
import {Octokit} from '@octokit/rest'
import {Commits} from './commits'
import { Commits, CommitInfo } from './commits';
import {PullRequestInfo, PullRequests} from './pullRequests'
import {buildChangelog} from './transform'
import * as core from '@actions/core'
@@ -52,9 +52,7 @@ export class ReleaseNotes {
const mergedPullRequests = await this.getMergedPullRequests(octokit)
if (mergedPullRequests.length === 0) {
core.warning(
`No pull requests found for between ${this.options.fromTag}...${toTag}`
)
core.warning(`No pull requests found`)
return configuration.empty_template
? configuration.empty_template
: DefaultConfiguration.empty_template
@@ -70,9 +68,15 @@ export class ReleaseNotes {
core.info(`Comparing ${owner}/${repo} - ${fromTag}...${toTag}`)
const commitsApi = new Commits(octokit)
const commits = await commitsApi.getDiff(owner, repo, fromTag!!, toTag)
let commits: CommitInfo[]
try {
commits = await commitsApi.getDiff(owner, repo, fromTag!!, toTag)
} catch (error) {
core.error(`Failed to retrieve - Invalid tag? - Because of: ${error}`)
return []
}
if (commits.length === 0) {
core.warning(`No commits found between - ${fromTag}...${toTag}`)
return []
}