Skip to content

Commit

Permalink
Use the head instead of the base for thisPR
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Aug 19, 2017
1 parent 42d0ea4 commit 1028073
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 34 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

It also still supports using TypeScript via the "`typescript"` module, if you have that installed. - orta

* `danger.github.thisPR` now uses the PR's head, not base - orta

### 2.0.0-alpha.8

* Uses the GitHub `diff_url` instead of the `diff` version header, as it conflicted with Peril - orta
Expand Down
6 changes: 3 additions & 3 deletions source/platforms/GitHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ export class GitHub {
}

/**
* Converts the PR JSON into something easily used by the Github API client
* Converts the PR JSON into something easily used by the Github API client.
*/
APIMetadataForPR(pr: GitHubPRDSL): GitHubAPIPR {
return {
number: pr.number,
repo: pr.base.repo.name,
owner: pr.base.repo.owner.login,
repo: pr.head.repo.name,
owner: pr.head.repo.owner.login,
}
}
}
10 changes: 10 additions & 0 deletions source/platforms/_tests/_github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,14 @@ describe("getPlatformDSLRepresentation", () => {
const { pr } = await github.getPlatformDSLRepresentation()
expect(pr.number).toEqual(327)
})

it("should set thisPR correct", async () => {
const dsl = await github.getPlatformDSLRepresentation()

expect(dsl.thisPR).toEqual({
number: 327,
owner: "orta",
repo: "emission",
})
})
})
56 changes: 28 additions & 28 deletions source/platforms/_tests/fixtures/github_pr.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,34 +81,34 @@
"comments_url": "https://api.github.com/repos/artsy/emission/issues/327/comments",
"statuses_url": "https://api.github.com/repos/artsy/emission/statuses/cfa8fb80d2b65f4c4fa0b54d25352a3a0ff58f75",
"head": {
"label": "artsy:genevc",
"label": "orta:genevc",
"ref": "genevc",
"sha": "cfa8fb80d2b65f4c4fa0b54d25352a3a0ff58f75",
"user": {
"login": "artsy",
"login": "orta",
"id": 546231,
"avatar_url": "https://avatars.githubusercontent.com/u/546231?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/artsy",
"html_url": "https://github.com/artsy",
"followers_url": "https://api.github.com/users/artsy/followers",
"following_url": "https://api.github.com/users/artsy/following{/other_user}",
"gists_url": "https://api.github.com/users/artsy/gists{/gist_id}",
"starred_url": "https://api.github.com/users/artsy/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/artsy/subscriptions",
"organizations_url": "https://api.github.com/users/artsy/orgs",
"repos_url": "https://api.github.com/users/artsy/repos",
"events_url": "https://api.github.com/users/artsy/events{/privacy}",
"received_events_url": "https://api.github.com/users/artsy/received_events",
"url": "https://api.github.com/users/orta",
"html_url": "https://github.com/orta",
"followers_url": "https://api.github.com/users/orta/followers",
"following_url": "https://api.github.com/users/orta/following{/other_user}",
"gists_url": "https://api.github.com/users/orta/gists{/gist_id}",
"starred_url": "https://api.github.com/users/orta/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/orta/subscriptions",
"organizations_url": "https://api.github.com/users/orta/orgs",
"repos_url": "https://api.github.com/users/orta/repos",
"events_url": "https://api.github.com/users/orta/events{/privacy}",
"received_events_url": "https://api.github.com/users/orta/received_events",
"type": "Organization",
"site_admin": false
},
"repo": {
"id": 52437732,
"name": "emission",
"full_name": "artsy/emission",
"full_name": "orta/emission",
"owner": {
"login": "artsy",
"login": "orta",
"id": 546231,
"avatar_url": "https://avatars.githubusercontent.com/u/546231?v=3",
"gravatar_id": "",
Expand All @@ -127,21 +127,21 @@
"site_admin": false
},
"private": false,
"html_url": "https://github.com/artsy/emission",
"html_url": "https://github.com/orta",
"description": "React Native Components",
"fork": false,
"url": "https://api.github.com/repos/artsy/emission",
"forks_url": "https://api.github.com/repos/artsy/emission/forks",
"keys_url": "https://api.github.com/repos/artsy/emission/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/artsy/emission/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/artsy/emission/teams",
"hooks_url": "https://api.github.com/repos/artsy/emission/hooks",
"issue_events_url": "https://api.github.com/repos/artsy/emission/issues/events{/number}",
"events_url": "https://api.github.com/repos/artsy/emission/events",
"assignees_url": "https://api.github.com/repos/artsy/emission/assignees{/user}",
"branches_url": "https://api.github.com/repos/artsy/emission/branches{/branch}",
"tags_url": "https://api.github.com/repos/artsy/emission/tags",
"blobs_url": "https://api.github.com/repos/artsy/emission/git/blobs{/sha}",
"url": "https://api.github.com/repos/orta",
"forks_url": "https://api.github.com/repos/orta/emission/forks",
"keys_url": "https://api.github.com/repos/orta/emission/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/orta/emission/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/orta/emission/teams",
"hooks_url": "https://api.github.com/repos/orta/emission/hooks",
"issue_events_url": "https://api.github.com/repos/orta/emission/issues/events{/number}",
"events_url": "https://api.github.com/repos/orta/emission/events",
"assignees_url": "https://api.github.com/repos/orta/emission/assignees{/user}",
"branches_url": "https://api.github.com/repos/orta/emission/branches{/branch}",
"tags_url": "https://api.github.com/repos/orta/emission/tags",
"blobs_url": "https://api.github.com/repos/orta/emission/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/artsy/emission/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/artsy/emission/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/artsy/emission/git/trees{/sha}",
Expand Down
6 changes: 3 additions & 3 deletions source/platforms/github/_tests/_github_utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ describe("fileLinks", () => {
it("Should convert a few paths into links", () => {
const sut = utils(pr, apiFake)
const links = sut.fileLinks(["a/b/c", "d/e/f"])
const url = "https://github.com/artsy/emission/blob/genevc/a/b/c"
const url = "https://github.com/orta/emission/blob/genevc/a/b/c"
expect(links).toEqual(
`<a href="${url}">c</a> and <a href="https://github.com/artsy/emission/blob/genevc/d/e/f">f</a>`
`<a href="${url}">c</a> and <a href="https://github.com/orta/emission/blob/genevc/d/e/f">f</a>`
)
})

it("Should convert a few paths into links showing full links", () => {
const sut = utils(pr, apiFake)
const links = sut.fileLinks(["a/b/c", "d/e/f"], false)
const url = "https://github.com/artsy/emission/blob/genevc"
const url = "https://github.com/orta/emission/blob/genevc"
expect(links).toEqual(`<a href="${url}/a/b/c">a/b/c</a> and <a href="${url}/d/e/f">d/e/f</a>`)
})

Expand Down

0 comments on commit 1028073

Please sign in to comment.