Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate query result for PR headRef #61

Merged
merged 1 commit into from
Oct 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/pull-request-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ export async function queryPullRequest (github: Context['github'], { owner, repo
if (!response) {
throw new Error(`Could not query pull request ${owner}/${repo}#${pullRequestNumber}`)
}
if (!response.repository) {
const error: any = new Error(`Query result does not have repository`)
if (!response.repository || !response.repository.pullRequest || !response.repository.pullRequest.headRef) {
const error: any = new Error(`Query result is not complete`)
error.pullRequest = `${owner}/${repo}#${pullRequestNumber}`
error.response = response
throw error
}

const queryResult = response as PullRequestQueryResult

const checks = result<{ check_runs: CheckRun[] }>(await github.checks.listForRef({
Expand Down