Skip to content

Commit

Permalink
Add Context#pullRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonEtco committed Jun 8, 2020
1 parent 33daf59 commit e5ec7ff
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class Context {
data.issue_number = payload.issue.number
} else if (payload.pull_request) {
// If it's a PR, the API expects pull_number
data.pull_number = payload.pull_request.number
data.issue_number = payload.pull_request.number
} else {
// Otherwise default to the old behaviour for BC reasons
// Long term, this should be data.number = payload.number
Expand All @@ -92,6 +92,21 @@ export class Context {
return data
}

public get pullRequest () {
const payload = this.payload

const data: { [k: string]: any } = {
...this.repo
}

if (payload.pull_request) {
// If it's a PR, the API expects pull_number
data.pull_number = payload.pull_request.number
}

return data
}

public get repo () {
if (process.env.GITHUB_REPOSITORY) {
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/')
Expand Down

0 comments on commit e5ec7ff

Please sign in to comment.