Fix "No commits between" error (#243)
This commit is contained in:
@@ -320,16 +320,23 @@
|
|||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.debug(error)
|
console.debug(error)
|
||||||
if (/A pull request already exists/.test(error)) {
|
//Check if pull request has already been created previously
|
||||||
info(`Pull request from ${committer.head} to ${committer.branch}`, "(already existing)")
|
if (/A pull request already exists/.test(error)) {
|
||||||
const q = `repo:${github.context.repo.owner}/${github.context.repo.repo}+type:pr+state:open+Auto-generated metrics for run #${github.context.runId}+in:title`
|
info(`Pull request from ${committer.head} to ${committer.branch}`, "(already existing)")
|
||||||
const prs = (await committer.rest.search.issuesAndPullRequests({q})).data.items.filter(({user:{login}}) => login === "github-actions[bot]")
|
const q = `repo:${github.context.repo.owner}/${github.context.repo.repo}+type:pr+state:open+Auto-generated metrics for run #${github.context.runId}+in:title`
|
||||||
if (prs.length < 1)
|
const prs = (await committer.rest.search.issuesAndPullRequests({q})).data.items.filter(({user:{login}}) => login === "github-actions[bot]")
|
||||||
throw new Error("0 matching prs. Cannot proceed.")
|
if (prs.length < 1)
|
||||||
if (prs.length > 1)
|
throw new Error("0 matching prs. Cannot proceed.")
|
||||||
throw new Error(`Found more than one matching prs: ${prs.map(({number}) => `#${number}`).join(", ")}. Cannot proceed.`)
|
if (prs.length > 1)
|
||||||
;({number} = prs.shift())
|
throw new Error(`Found more than one matching prs: ${prs.map(({number}) => `#${number}`).join(", ")}. Cannot proceed.`)
|
||||||
}
|
;({number} = prs.shift())
|
||||||
|
}
|
||||||
|
//Check if pull request could not been created because there are no diff between head and base
|
||||||
|
else if (/No commits between/.test(error)) {
|
||||||
|
info(`Pull request from ${committer.head} to ${committer.branch}`, "(no diff)")
|
||||||
|
committer.merge = false
|
||||||
|
number = "(none)"
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user