fetchGithubRepo: remove vestigial data field (#142)

The example-repo.json file is regenerated with large diffs due to the
change in indentation level throughout the file.

Test plan:
Sanity check the snapshot (close inspection is unnecessary due to the
simplicity of the code change). Check that CI pases.
This commit is contained in:
Dandelion Mané 2018-04-24 15:46:16 -07:00 committed by GitHub
parent 6a3e4d754c
commit 8fdfacd097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 301 additions and 306 deletions

View File

@ -14,7 +14,7 @@ require("../testUtil").configureEnzyme();
describe("githubPluginAdapter", () => { describe("githubPluginAdapter", () => {
it("operates on the example repo", () => { it("operates on the example repo", () => {
const parser = new GithubParser("sourcecred/example-repo"); const parser = new GithubParser("sourcecred/example-repo");
parser.addData(exampleRepoData.data); parser.addData(exampleRepoData);
const graph = parser.graph; const graph = parser.graph;
const result = graph const result = graph

View File

@ -1,312 +1,310 @@
{ {
"data": { "repository": {
"repository": { "id": "MDEwOlJlcG9zaXRvcnkxMjMyNTUwMDY=",
"id": "MDEwOlJlcG9zaXRvcnkxMjMyNTUwMDY=", "issues": {
"issues": { "nodes": [
"nodes": [ {
{ "author": {
"author": { "__typename": "User",
"__typename": "User", "id": "MDQ6VXNlcjE0MDAwMjM=",
"id": "MDQ6VXNlcjE0MDAwMjM=", "login": "decentralion",
"login": "decentralion", "url": "https://github.com/decentralion"
"url": "https://github.com/decentralion"
},
"body": "This is just an example issue.",
"comments": {
"nodes": [
],
"pageInfo": {
"endCursor": null,
"hasNextPage": false
}
},
"id": "MDU6SXNzdWUzMDA5MzQ4MTg=",
"number": 1,
"title": "An example issue.",
"url": "https://github.com/sourcecred/example-repo/issues/1"
}, },
{ "body": "This is just an example issue.",
"author": { "comments": {
"__typename": "User", "nodes": [
"id": "MDQ6VXNlcjE0MDAwMjM=", ],
"login": "decentralion", "pageInfo": {
"url": "https://github.com/decentralion" "endCursor": null,
}, "hasNextPage": false
"body": "This issue references another issue, namely #1", }
"comments": { },
"nodes": [ "id": "MDU6SXNzdWUzMDA5MzQ4MTg=",
{ "number": 1,
"author": { "title": "An example issue.",
"__typename": "User", "url": "https://github.com/sourcecred/example-repo/issues/1"
"id": "MDQ6VXNlcjE0MDAwMjM=", },
"login": "decentralion", {
"url": "https://github.com/decentralion" "author": {
}, "__typename": "User",
"body": "It should also be possible to reference by exact url: https://github.com/sourcecred/example-repo/issues/6", "id": "MDQ6VXNlcjE0MDAwMjM=",
"id": "MDEyOklzc3VlQ29tbWVudDM3Mzc2ODcwMw==", "login": "decentralion",
"url": "https://github.com/sourcecred/example-repo/issues/2#issuecomment-373768703" "url": "https://github.com/decentralion"
},
"body": "This issue references another issue, namely #1",
"comments": {
"nodes": [
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjE0MDAwMjM=",
"login": "decentralion",
"url": "https://github.com/decentralion"
}, },
{ "body": "It should also be possible to reference by exact url: https://github.com/sourcecred/example-repo/issues/6",
"author": { "id": "MDEyOklzc3VlQ29tbWVudDM3Mzc2ODcwMw==",
"__typename": "User", "url": "https://github.com/sourcecred/example-repo/issues/2#issuecomment-373768703"
"id": "MDQ6VXNlcjE0MDAwMjM=", },
"login": "decentralion", {
"url": "https://github.com/decentralion" "author": {
}, "__typename": "User",
"body": "We might also reference individual comments directly.\r\nhttps://github.com/sourcecred/example-repo/issues/6#issuecomment-373768538", "id": "MDQ6VXNlcjE0MDAwMjM=",
"id": "MDEyOklzc3VlQ29tbWVudDM3Mzc2ODg1MA==", "login": "decentralion",
"url": "https://github.com/sourcecred/example-repo/issues/2#issuecomment-373768850" "url": "https://github.com/decentralion"
}
],
"pageInfo": {
"endCursor": "Y3Vyc29yOnYyOpHOFkdCkg==",
"hasNextPage": false
}
},
"id": "MDU6SXNzdWUzMDA5MzQ5ODA=",
"number": 2,
"title": "A referencing issue.",
"url": "https://github.com/sourcecred/example-repo/issues/2"
},
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjE0MDAwMjM=",
"login": "decentralion",
"url": "https://github.com/decentralion"
},
"body": "Alas, its life as an open issue had only just begun.",
"comments": {
"nodes": [
],
"pageInfo": {
"endCursor": null,
"hasNextPage": false
}
},
"id": "MDU6SXNzdWUzMDA5MzYzNzQ=",
"number": 4,
"title": "A closed pull request",
"url": "https://github.com/sourcecred/example-repo/issues/4"
},
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjE0MDAwMjM=",
"login": "decentralion",
"url": "https://github.com/decentralion"
},
"body": "This issue shall shortly have a few comments.",
"comments": {
"nodes": [
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjE0MDAwMjM=",
"login": "decentralion",
"url": "https://github.com/decentralion"
},
"body": "A wild COMMENT appeared!",
"id": "MDEyOklzc3VlQ29tbWVudDM3Mzc2ODQ0Mg==",
"url": "https://github.com/sourcecred/example-repo/issues/6#issuecomment-373768442"
}, },
{ "body": "We might also reference individual comments directly.\r\nhttps://github.com/sourcecred/example-repo/issues/6#issuecomment-373768538",
"author": { "id": "MDEyOklzc3VlQ29tbWVudDM3Mzc2ODg1MA==",
"__typename": "User", "url": "https://github.com/sourcecred/example-repo/issues/2#issuecomment-373768850"
"id": "MDQ6VXNlcjE0MDAwMjM=",
"login": "decentralion",
"url": "https://github.com/decentralion"
},
"body": "And the maintainer said, \"Let there be comments!\"",
"id": "MDEyOklzc3VlQ29tbWVudDM3Mzc2ODUzOA==",
"url": "https://github.com/sourcecred/example-repo/issues/6#issuecomment-373768538"
}
],
"pageInfo": {
"endCursor": "Y3Vyc29yOnYyOpHOFkdBWg==",
"hasNextPage": false
} }
}, ],
"id": "MDU6SXNzdWUzMDU5OTM3NzM=", "pageInfo": {
"number": 6, "endCursor": "Y3Vyc29yOnYyOpHOFkdCkg==",
"title": "An issue with comments", "hasNextPage": false
"url": "https://github.com/sourcecred/example-repo/issues/6" }
}, },
{ "id": "MDU6SXNzdWUzMDA5MzQ5ODA=",
"author": { "number": 2,
"__typename": "User", "title": "A referencing issue.",
"id": "MDQ6VXNlcjE0MDAwMjM=", "url": "https://github.com/sourcecred/example-repo/issues/2"
"login": "decentralion", },
"url": "https://github.com/decentralion" {
}, "author": {
"body": "Deal with this, naive string display algorithms!!!!!", "__typename": "User",
"comments": { "id": "MDQ6VXNlcjE0MDAwMjM=",
"nodes": [ "login": "decentralion",
], "url": "https://github.com/decentralion"
"pageInfo": {
"endCursor": null,
"hasNextPage": false
}
},
"id": "MDU6SXNzdWUzMDY5ODM1NTI=",
"number": 7,
"title": "An issue with an extremely long title, which even has a VerySuperFragicalisticialiManyCharacterUberLongTriplePlusGood word in it, and should really be truncated intelligently or something",
"url": "https://github.com/sourcecred/example-repo/issues/7"
}, },
{ "body": "Alas, its life as an open issue had only just begun.",
"author": { "comments": {
"__typename": "User", "nodes": [
"id": "MDQ6VXNlcjE0MDAwMjM=", ],
"login": "decentralion", "pageInfo": {
"url": "https://github.com/decentralion" "endCursor": null,
}, "hasNextPage": false
"body": "Issue with Unicode: ȴሲ𣐳楢👍 :heart: 𐤔𐤁𐤀𐤑𐤍𐤉𐤔𐤌𐤄𐤍𐤍 ❤️\r\nIssue with Unicode: ȴሲ𣐳楢👍 :heart: 𐤔𐤁𐤀𐤑𐤍𐤉𐤔𐤌𐤄𐤍𐤍 ❤️", }
"comments": { },
"nodes": [ "id": "MDU6SXNzdWUzMDA5MzYzNzQ=",
], "number": 4,
"pageInfo": { "title": "A closed pull request",
"endCursor": null, "url": "https://github.com/sourcecred/example-repo/issues/4"
"hasNextPage": false },
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjE0MDAwMjM=",
"login": "decentralion",
"url": "https://github.com/decentralion"
},
"body": "This issue shall shortly have a few comments.",
"comments": {
"nodes": [
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjE0MDAwMjM=",
"login": "decentralion",
"url": "https://github.com/decentralion"
},
"body": "A wild COMMENT appeared!",
"id": "MDEyOklzc3VlQ29tbWVudDM3Mzc2ODQ0Mg==",
"url": "https://github.com/sourcecred/example-repo/issues/6#issuecomment-373768442"
},
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjE0MDAwMjM=",
"login": "decentralion",
"url": "https://github.com/decentralion"
},
"body": "And the maintainer said, \"Let there be comments!\"",
"id": "MDEyOklzc3VlQ29tbWVudDM3Mzc2ODUzOA==",
"url": "https://github.com/sourcecred/example-repo/issues/6#issuecomment-373768538"
} }
}, ],
"id": "MDU6SXNzdWUzMDY5ODUzNjc=", "pageInfo": {
"number": 8, "endCursor": "Y3Vyc29yOnYyOpHOFkdBWg==",
"title": "Issue with Unicode: ȴሲ𣐳楢👍 :heart: 𐤔𐤁𐤀𐤑𐤍𐤉𐤔𐤌𐤄𐤍𐤍 ❤️", "hasNextPage": false
"url": "https://github.com/sourcecred/example-repo/issues/8" }
} },
], "id": "MDU6SXNzdWUzMDU5OTM3NzM=",
"pageInfo": { "number": 6,
"endCursor": "Y3Vyc29yOnYyOpHOEkw5lw==", "title": "An issue with comments",
"hasNextPage": false "url": "https://github.com/sourcecred/example-repo/issues/6"
},
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjE0MDAwMjM=",
"login": "decentralion",
"url": "https://github.com/decentralion"
},
"body": "Deal with this, naive string display algorithms!!!!!",
"comments": {
"nodes": [
],
"pageInfo": {
"endCursor": null,
"hasNextPage": false
}
},
"id": "MDU6SXNzdWUzMDY5ODM1NTI=",
"number": 7,
"title": "An issue with an extremely long title, which even has a VerySuperFragicalisticialiManyCharacterUberLongTriplePlusGood word in it, and should really be truncated intelligently or something",
"url": "https://github.com/sourcecred/example-repo/issues/7"
},
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjE0MDAwMjM=",
"login": "decentralion",
"url": "https://github.com/decentralion"
},
"body": "Issue with Unicode: ȴሲ𣐳楢👍 :heart: 𐤔𐤁𐤀𐤑𐤍𐤉𐤔𐤌𐤄𐤍𐤍 ❤️\r\nIssue with Unicode: ȴሲ𣐳楢👍 :heart: 𐤔𐤁𐤀𐤑𐤍𐤉𐤔𐤌𐤄𐤍𐤍 ❤️",
"comments": {
"nodes": [
],
"pageInfo": {
"endCursor": null,
"hasNextPage": false
}
},
"id": "MDU6SXNzdWUzMDY5ODUzNjc=",
"number": 8,
"title": "Issue with Unicode: ȴሲ𣐳楢👍 :heart: 𐤔𐤁𐤀𐤑𐤍𐤉𐤔𐤌𐤄𐤍𐤍 ❤️",
"url": "https://github.com/sourcecred/example-repo/issues/8"
} }
}, ],
"pullRequests": { "pageInfo": {
"nodes": [ "endCursor": "Y3Vyc29yOnYyOpHOEkw5lw==",
{ "hasNextPage": false
"author": { }
"__typename": "User", },
"id": "MDQ6VXNlcjE0MDAwMjM=", "pullRequests": {
"login": "decentralion", "nodes": [
"url": "https://github.com/decentralion" {
}, "author": {
"body": "Oh look, it's a pull request.", "__typename": "User",
"comments": { "id": "MDQ6VXNlcjE0MDAwMjM=",
"nodes": [ "login": "decentralion",
{ "url": "https://github.com/decentralion"
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjE0MDAwMjM=",
"login": "decentralion",
"url": "https://github.com/decentralion"
},
"body": "It seems apropos to reference something from a pull request comment... eg: #2 ",
"id": "MDEyOklzc3VlQ29tbWVudDM2OTE2MjIyMg==",
"url": "https://github.com/sourcecred/example-repo/pull/3#issuecomment-369162222"
}
],
"pageInfo": {
"endCursor": "Y3Vyc29yOnYyOpHOFgD37g==",
"hasNextPage": false
}
},
"id": "MDExOlB1bGxSZXF1ZXN0MTcxODg3NzQx",
"number": 3,
"reviews": {
"nodes": [
],
"pageInfo": {
"endCursor": null,
"hasNextPage": false
}
},
"title": "Add README, merge via PR.",
"url": "https://github.com/sourcecred/example-repo/pull/3"
}, },
{ "body": "Oh look, it's a pull request.",
"author": { "comments": {
"__typename": "User", "nodes": [
"id": "MDQ6VXNlcjE0MDAwMjM=", {
"login": "decentralion", "author": {
"url": "https://github.com/decentralion" "__typename": "User",
}, "id": "MDQ6VXNlcjE0MDAwMjM=",
"body": "@wchargin could you please do the following:\r\n- add a commit comment\r\n- add a review comment requesting some trivial change\r\n- i'll change it\r\n- then approve the pr", "login": "decentralion",
"comments": { "url": "https://github.com/decentralion"
"nodes": [
],
"pageInfo": {
"endCursor": null,
"hasNextPage": false
}
},
"id": "MDExOlB1bGxSZXF1ZXN0MTcxODg4NTIy",
"number": 5,
"reviews": {
"nodes": [
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjQzMTc4MDY=",
"login": "wchargin",
"url": "https://github.com/wchargin"
},
"body": "hmmm.jpg",
"comments": {
"nodes": [
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjQzMTc4MDY=",
"login": "wchargin",
"url": "https://github.com/wchargin"
},
"body": "seems a bit capricious",
"id": "MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE3MTQ2MDE5OA==",
"url": "https://github.com/sourcecred/example-repo/pull/5#discussion_r171460198"
}
],
"pageInfo": {
"endCursor": "Y3Vyc29yOnYyOpK0MjAxOC0wMy0wMVQwNDoyMzozMFrOCjhGZg==",
"hasNextPage": false
}
},
"id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3MTAwMzEzODk5",
"state": "CHANGES_REQUESTED",
"url": "https://github.com/sourcecred/example-repo/pull/5#pullrequestreview-100313899"
}, },
{ "body": "It seems apropos to reference something from a pull request comment... eg: #2 ",
"author": { "id": "MDEyOklzc3VlQ29tbWVudDM2OTE2MjIyMg==",
"__typename": "User", "url": "https://github.com/sourcecred/example-repo/pull/3#issuecomment-369162222"
"id": "MDQ6VXNlcjQzMTc4MDY=",
"login": "wchargin",
"url": "https://github.com/wchargin"
},
"body": "I'm sold",
"comments": {
"nodes": [
],
"pageInfo": {
"endCursor": null,
"hasNextPage": false
}
},
"id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3MTAwMzE0MDM4",
"state": "APPROVED",
"url": "https://github.com/sourcecred/example-repo/pull/5#pullrequestreview-100314038"
}
],
"pageInfo": {
"endCursor": "Y3Vyc29yOnYyOpO5MjAxOC0wMi0yOFQyMDoyNDo1Ni0wODowMLkyMDE4LTAyLTI4VDIwOjI0OjU2LTA4OjAwzgX6q7Y=",
"hasNextPage": false
} }
}, ],
"title": "This pull request will be more contentious. I can feel it...", "pageInfo": {
"url": "https://github.com/sourcecred/example-repo/pull/5" "endCursor": "Y3Vyc29yOnYyOpHOFgD37g==",
} "hasNextPage": false
], }
"pageInfo": { },
"endCursor": "Y3Vyc29yOnYyOpHOCj7Pig==", "id": "MDExOlB1bGxSZXF1ZXN0MTcxODg3NzQx",
"hasNextPage": false "number": 3,
"reviews": {
"nodes": [
],
"pageInfo": {
"endCursor": null,
"hasNextPage": false
}
},
"title": "Add README, merge via PR.",
"url": "https://github.com/sourcecred/example-repo/pull/3"
},
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjE0MDAwMjM=",
"login": "decentralion",
"url": "https://github.com/decentralion"
},
"body": "@wchargin could you please do the following:\r\n- add a commit comment\r\n- add a review comment requesting some trivial change\r\n- i'll change it\r\n- then approve the pr",
"comments": {
"nodes": [
],
"pageInfo": {
"endCursor": null,
"hasNextPage": false
}
},
"id": "MDExOlB1bGxSZXF1ZXN0MTcxODg4NTIy",
"number": 5,
"reviews": {
"nodes": [
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjQzMTc4MDY=",
"login": "wchargin",
"url": "https://github.com/wchargin"
},
"body": "hmmm.jpg",
"comments": {
"nodes": [
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjQzMTc4MDY=",
"login": "wchargin",
"url": "https://github.com/wchargin"
},
"body": "seems a bit capricious",
"id": "MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE3MTQ2MDE5OA==",
"url": "https://github.com/sourcecred/example-repo/pull/5#discussion_r171460198"
}
],
"pageInfo": {
"endCursor": "Y3Vyc29yOnYyOpK0MjAxOC0wMy0wMVQwNDoyMzozMFrOCjhGZg==",
"hasNextPage": false
}
},
"id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3MTAwMzEzODk5",
"state": "CHANGES_REQUESTED",
"url": "https://github.com/sourcecred/example-repo/pull/5#pullrequestreview-100313899"
},
{
"author": {
"__typename": "User",
"id": "MDQ6VXNlcjQzMTc4MDY=",
"login": "wchargin",
"url": "https://github.com/wchargin"
},
"body": "I'm sold",
"comments": {
"nodes": [
],
"pageInfo": {
"endCursor": null,
"hasNextPage": false
}
},
"id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3MTAwMzE0MDM4",
"state": "APPROVED",
"url": "https://github.com/sourcecred/example-repo/pull/5#pullrequestreview-100314038"
}
],
"pageInfo": {
"endCursor": "Y3Vyc29yOnYyOpO5MjAxOC0wMi0yOFQyMDoyNDo1Ni0wODowMLkyMDE4LTAyLTI4VDIwOjI0OjU2LTA4OjAwzgX6q7Y=",
"hasNextPage": false
}
},
"title": "This pull request will be more contentious. I can feel it...",
"url": "https://github.com/sourcecred/example-repo/pull/5"
} }
],
"pageInfo": {
"endCursor": "Y3Vyc29yOnYyOpHOCj7Pig==",
"hasNextPage": false
} }
} }
} }

View File

@ -53,10 +53,7 @@ export default function fetchGithubRepo(
payload payload
).then((x) => { ).then((x) => {
ensureNoMorePages(x); ensureNoMorePages(x);
// TODO: We wrap back up in the "data" object to maintain return x;
// compatibility. At some point, let's strip this out and modify
// clients of `example-data.json`.
return {data: x};
}); });
} }

View File

@ -8,7 +8,7 @@ import exampleRepoData from "./demoData/example-repo.json";
describe("GithubParser", () => { describe("GithubParser", () => {
describe("whole repo parsing", () => { describe("whole repo parsing", () => {
const parser = new GithubParser("sourcecred/example-repo"); const parser = new GithubParser("sourcecred/example-repo");
parser.addData(exampleRepoData.data); parser.addData(exampleRepoData);
const graph = parser.graph; const graph = parser.graph;
it("parses the entire example-repo as expected", () => { it("parses the entire example-repo as expected", () => {
@ -68,7 +68,7 @@ describe("GithubParser", () => {
describe("issue parsing", () => { describe("issue parsing", () => {
it("parses a simple issue (https://github.com/sourcecred/example-repo/issues/1)", () => { it("parses a simple issue (https://github.com/sourcecred/example-repo/issues/1)", () => {
const issue1 = exampleRepoData.data.repository.issues.nodes[0]; const issue1 = exampleRepoData.repository.issues.nodes[0];
expect(issue1.number).toBe(1); expect(issue1.number).toBe(1);
const parser = new GithubParser("sourcecred/example-repo"); const parser = new GithubParser("sourcecred/example-repo");
parser.addIssue(issue1); parser.addIssue(issue1);
@ -76,7 +76,7 @@ describe("GithubParser", () => {
}); });
it("parses an issue with comments (https://github.com/sourcecred/example-repo/issues/6)", () => { it("parses an issue with comments (https://github.com/sourcecred/example-repo/issues/6)", () => {
const issue6 = exampleRepoData.data.repository.issues.nodes[3]; const issue6 = exampleRepoData.repository.issues.nodes[3];
expect(issue6.number).toBe(6); expect(issue6.number).toBe(6);
const parser = new GithubParser("sourcecred/example-repo"); const parser = new GithubParser("sourcecred/example-repo");
parser.addIssue(issue6); parser.addIssue(issue6);
@ -86,14 +86,14 @@ describe("GithubParser", () => {
describe("pull request parsing", () => { describe("pull request parsing", () => {
it("parses a simple pull request (https://github.com/sourcecred/example-repo/pull/3)", () => { it("parses a simple pull request (https://github.com/sourcecred/example-repo/pull/3)", () => {
const pr3 = exampleRepoData.data.repository.pullRequests.nodes[0]; const pr3 = exampleRepoData.repository.pullRequests.nodes[0];
expect(pr3.number).toBe(3); expect(pr3.number).toBe(3);
const parser = new GithubParser("sourcecred/example-repo"); const parser = new GithubParser("sourcecred/example-repo");
parser.addPullRequest(pr3); parser.addPullRequest(pr3);
expect(parser.graph).toMatchSnapshot(); expect(parser.graph).toMatchSnapshot();
}); });
it("parses a pr with review comments (https://github.com/sourcecred/example-repo/pull/3)", () => { it("parses a pr with review comments (https://github.com/sourcecred/example-repo/pull/3)", () => {
const pr5 = exampleRepoData.data.repository.pullRequests.nodes[1]; const pr5 = exampleRepoData.repository.pullRequests.nodes[1];
expect(pr5.number).toBe(5); expect(pr5.number).toBe(5);
const parser = new GithubParser("sourcecred/example-repo"); const parser = new GithubParser("sourcecred/example-repo");
parser.addPullRequest(pr5); parser.addPullRequest(pr5);