Skip to content

Commit

Permalink
Merge pull request #1416 from radimsv/fix/gh-thispr
Browse files Browse the repository at this point in the history
fix: Github thisPR attributes
  • Loading branch information
orta committed Dec 7, 2023
2 parents 263bcd2 + 0df7623 commit 98201b8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
21 changes: 13 additions & 8 deletions source/dsl/GitHubDSL.ts
Expand Up @@ -289,13 +289,13 @@ export interface GitHubPRDSL {

/** How does the PR author relate to this repo/org? */
author_association:
| "COLLABORATOR"
| "CONTRIBUTOR"
| "FIRST_TIMER"
| "FIRST_TIME_CONTRIBUTOR"
| "MEMBER"
| "NONE"
| "OWNER"
| "COLLABORATOR"
| "CONTRIBUTOR"
| "FIRST_TIMER"
| "FIRST_TIME_CONTRIBUTOR"
| "MEMBER"
| "NONE"
| "OWNER"
}

// These are the individual subtypes of objects inside the larger DSL objects above.
Expand Down Expand Up @@ -462,8 +462,13 @@ export interface GitHubAPIPR {
owner: string
/** The repo name */
repo: string
/** The PR number */
/**
* The PR number
* @deprecated use `pull_number` instead
*/
number: number
/** The PR number */
pull_number: number
}

export interface GitHubReviewers {
Expand Down
1 change: 1 addition & 0 deletions source/platforms/GitHub.ts
Expand Up @@ -20,6 +20,7 @@ export function GitHub(api: GitHubAPI) {
const APIMetadataForPR = (pr: GitHubPRDSL): GitHubAPIPR => {
return {
number: pr.number,
pull_number: pr.number,
repo: pr.base.repo.name,
owner: pr.base.repo.owner.login,
}
Expand Down
5 changes: 3 additions & 2 deletions source/platforms/_tests/_github.test.ts
Expand Up @@ -7,8 +7,8 @@ const fixtures = resolve(__dirname, "fixtures")
// eslint-disable-next-line jest/no-export
export const requestWithFixturedJSON =
async (path: string): Promise<() => Promise<any>> =>
() =>
Promise.resolve(JSON.parse(readFileSync(`${fixtures}/${path}`, {}).toString()))
() =>
Promise.resolve(JSON.parse(readFileSync(`${fixtures}/${path}`, {}).toString()))

class mockGitHubAPI {
async getPullRequestInfo() {
Expand Down Expand Up @@ -103,6 +103,7 @@ describe("getPlatformReviewDSLRepresentation", () => {
const dsl = await github.getPlatformReviewDSLRepresentation()

expect(dsl.thisPR).toEqual({
pull_number: 327,
number: 327,
owner: "artsy",
repo: "emission",
Expand Down

0 comments on commit 98201b8

Please sign in to comment.