From ad9ac55bef4aaa6fbe56c5c80f4964bf2f319665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dandelion=20Man=C3=A9?= Date: Wed, 13 Jun 2018 13:41:52 -0700 Subject: [PATCH] Github Addresses: Rename `fragment` to `id` (#386) Test plan: `yarn travis` --- .../github/__snapshots__/nodes.test.js.snap | 10 +++--- src/v3/plugins/github/nodes.js | 32 +++++++++---------- src/v3/plugins/github/nodes.test.js | 18 +++++------ 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/v3/plugins/github/__snapshots__/nodes.test.js.snap b/src/v3/plugins/github/__snapshots__/nodes.test.js.snap index edede3f..6f83e98 100644 --- a/src/v3/plugins/github/__snapshots__/nodes.test.js.snap +++ b/src/v3/plugins/github/__snapshots__/nodes.test.js.snap @@ -35,7 +35,7 @@ Object { "373768703", ], "structured": Object { - "fragment": "373768703", + "id": "373768703", "parent": Object { "number": "2", "repo": Object { @@ -85,7 +85,7 @@ Object { "396430464", ], "structured": Object { - "fragment": "396430464", + "id": "396430464", "parent": Object { "number": "5", "repo": Object { @@ -129,7 +129,7 @@ Object { "100313899", ], "structured": Object { - "fragment": "100313899", + "id": "100313899", "pull": Object { "number": "5", "repo": Object { @@ -158,9 +158,9 @@ Object { "171460198", ], "structured": Object { - "fragment": "171460198", + "id": "171460198", "parent": Object { - "fragment": "100313899", + "id": "100313899", "pull": Object { "number": "5", "repo": Object { diff --git a/src/v3/plugins/github/nodes.js b/src/v3/plugins/github/nodes.js index 9febd82..2d8bd33 100644 --- a/src/v3/plugins/github/nodes.js +++ b/src/v3/plugins/github/nodes.js @@ -27,12 +27,12 @@ export type PullAddress = {| export type ReviewAddress = {| +type: "REVIEW", +pull: PullAddress, - +fragment: string, + +id: string, |}; export type CommentAddress = {| +type: "COMMENT", +parent: IssueAddress | PullAddress | ReviewAddress, - +fragment: string, + +id: string, |}; export type UserlikeAddress = {| +type: "USERLIKE", @@ -83,10 +83,10 @@ export function fromRaw(x: RawAddress): StructuredAddress { if (rest.length !== 4) { throw fail(); } - const [owner, name, pullNumber, fragment] = rest; + const [owner, name, pullNumber, id] = rest; const repo = {type: "REPO", owner, name}; const pull = {type: "PULL", repo, number: pullNumber}; - return {type: "REVIEW", pull, fragment}; + return {type: "REVIEW", pull, id}; } case "comment": { if (rest.length < 1) { @@ -98,29 +98,29 @@ export function fromRaw(x: RawAddress): StructuredAddress { if (subrest.length !== 4) { throw fail(); } - const [owner, name, issueNumber, fragment] = subrest; + const [owner, name, issueNumber, id] = subrest; const repo = {type: "REPO", owner, name}; const issue = {type: "ISSUE", repo, number: issueNumber}; - return {type: "COMMENT", parent: issue, fragment}; + return {type: "COMMENT", parent: issue, id}; } case "pull": { if (subrest.length !== 4) { throw fail(); } - const [owner, name, pullNumber, fragment] = subrest; + const [owner, name, pullNumber, id] = subrest; const repo = {type: "REPO", owner, name}; const pull = {type: "PULL", repo, number: pullNumber}; - return {type: "COMMENT", parent: pull, fragment}; + return {type: "COMMENT", parent: pull, id}; } case "review": { if (subrest.length !== 5) { throw fail(); } - const [owner, name, pullNumber, reviewFragment, fragment] = subrest; + const [owner, name, pullNumber, reviewFragment, id] = subrest; const repo = {type: "REPO", owner, name}; const pull = {type: "PULL", repo, number: pullNumber}; - const review = {type: "REVIEW", pull, fragment: reviewFragment}; - return {type: "COMMENT", parent: review, fragment}; + const review = {type: "REVIEW", pull, id: reviewFragment}; + return {type: "COMMENT", parent: review, id}; } default: throw fail(); @@ -152,7 +152,7 @@ export function toRaw(x: StructuredAddress): RawAddress { x.pull.repo.owner, x.pull.repo.name, x.pull.number, - x.fragment + x.id ); case "COMMENT": switch (x.parent.type) { @@ -163,7 +163,7 @@ export function toRaw(x: StructuredAddress): RawAddress { x.parent.repo.owner, x.parent.repo.name, x.parent.number, - x.fragment + x.id ); case "PULL": return githubAddress( @@ -172,7 +172,7 @@ export function toRaw(x: StructuredAddress): RawAddress { x.parent.repo.owner, x.parent.repo.name, x.parent.number, - x.fragment + x.id ); case "REVIEW": return githubAddress( @@ -181,8 +181,8 @@ export function toRaw(x: StructuredAddress): RawAddress { x.parent.pull.repo.owner, x.parent.pull.repo.name, x.parent.pull.number, - x.parent.fragment, - x.fragment + x.parent.id, + x.id ); default: // eslint-disable-next-line no-unused-expressions diff --git a/src/v3/plugins/github/nodes.test.js b/src/v3/plugins/github/nodes.test.js index d2df368..941916b 100644 --- a/src/v3/plugins/github/nodes.test.js +++ b/src/v3/plugins/github/nodes.test.js @@ -11,21 +11,21 @@ describe("plugins/github/nodes", () => { }); const issue = () => ({type: "ISSUE", repo: repo(), number: "2"}); const pull = () => ({type: "PULL", repo: repo(), number: "5"}); - const review = () => ({type: "REVIEW", pull: pull(), fragment: "100313899"}); + const review = () => ({type: "REVIEW", pull: pull(), id: "100313899"}); const issueComment = () => ({ type: "COMMENT", parent: issue(), - fragment: "373768703", + id: "373768703", }); const pullComment = () => ({ type: "COMMENT", parent: pull(), - fragment: "396430464", + id: "396430464", }); const reviewComment = () => ({ type: "COMMENT", parent: review(), - fragment: "171460198", + id: "171460198", }); const user = () => ({type: "USERLIKE", login: "decentralion"}); const examples = { @@ -137,7 +137,7 @@ describe("plugins/github/nodes", () => { {name: "no owner", parts: ["review"]}, {name: "no name", parts: ["owner"]}, {name: "no number", parts: ["name"]}, - {name: "no fragment", parts: ["123"]}, + {name: "no id", parts: ["123"]}, {name: "extra parts", parts: ["987", "foo"]}, ]); }); @@ -149,7 +149,7 @@ describe("plugins/github/nodes", () => { {name: "no owner", parts: ["comment", "issue"]}, {name: "no name", parts: ["owner"]}, {name: "no number", parts: ["name"]}, - {name: "no fragment", parts: ["123"]}, + {name: "no id", parts: ["123"]}, {name: "extra parts", parts: ["987", "foo"]}, ]); }); @@ -158,7 +158,7 @@ describe("plugins/github/nodes", () => { {name: "no owner", parts: ["comment", "pull"]}, {name: "no name", parts: ["owner"]}, {name: "no number", parts: ["name"]}, - {name: "no fragment", parts: ["123"]}, + {name: "no id", parts: ["123"]}, {name: "extra parts", parts: ["987", "foo"]}, ]); }); @@ -167,8 +167,8 @@ describe("plugins/github/nodes", () => { {name: "no owner", parts: ["comment", "review"]}, {name: "no name", parts: ["owner"]}, {name: "no number", parts: ["name"]}, - {name: "no review fragment", parts: ["123"]}, - {name: "no comment fragment", parts: ["987"]}, + {name: "no review id", parts: ["123"]}, + {name: "no comment id", parts: ["987"]}, {name: "extra parts", parts: ["654", "foo"]}, ]); });