Use urls as ids for GitHub nodes (#144)

There's some context at #127, in which I initially proposed this change.

In addition to the long-term benefits described in #127, there is a
short-term benefit which is that it makes snapshot tests easier to read,
because the GitHub ids are opaque and unreadable, while the GitHub urls
are relatively easy to parse.

This change results in significant snapshot churn.
This commit is contained in:
Dandelion Mané 2018-04-25 14:28:06 -07:00 committed by GitHub
parent 4f857a8bb1
commit ad56ba087c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 724 additions and 724 deletions

View File

@ -3,37 +3,175 @@
exports[`githubPluginAdapter operates on the example repo 1`] = ` exports[`githubPluginAdapter operates on the example repo 1`] = `
Array [ Array [
Object { Object {
"id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3MTAwMzE0MDM4", "id": "https://github.com/decentralion",
"payload": Object { "payload": Object {
"body": "I'm sold", "login": "decentralion",
"state": "APPROVED", "url": "https://github.com/decentralion",
"url": "https://github.com/sourcecred/example-repo/pull/5#pullrequestreview-100314038",
}, },
"rendered": <div> "rendered": <div>
type: type:
PULL_REQUEST_REVIEW USER
(details to be implemented) (details to be implemented)
</div>, </div>,
"title": "review of #5: This pull request will be more contentious. I can feel it...", "title": "decentralion",
"type": "PULL_REQUEST_REVIEW", "type": "USER",
}, },
Object { Object {
"id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3MTAwMzEzODk5", "id": "https://github.com/sourcecred/example-repo/issues/1",
"payload": Object { "payload": Object {
"body": "hmmm.jpg", "body": "This is just an example issue.",
"state": "CHANGES_REQUESTED", "number": 1,
"url": "https://github.com/sourcecred/example-repo/pull/5#pullrequestreview-100313899", "title": "An example issue.",
"url": "https://github.com/sourcecred/example-repo/issues/1",
}, },
"rendered": <div> "rendered": <div>
type: type:
PULL_REQUEST_REVIEW ISSUE
(details to be implemented) (details to be implemented)
</div>, </div>,
"title": "review of #5: This pull request will be more contentious. I can feel it...", "title": "#1: An example issue.",
"type": "PULL_REQUEST_REVIEW", "type": "ISSUE",
}, },
Object { Object {
"id": "MDExOlB1bGxSZXF1ZXN0MTcxODg3NzQx", "id": "https://github.com/sourcecred/example-repo/issues/2",
"payload": Object {
"body": "This issue references another issue, namely #1",
"number": 2,
"title": "A referencing issue.",
"url": "https://github.com/sourcecred/example-repo/issues/2",
},
"rendered": <div>
type:
ISSUE
(details to be implemented)
</div>,
"title": "#2: A referencing issue.",
"type": "ISSUE",
},
Object {
"id": "https://github.com/sourcecred/example-repo/issues/2#issuecomment-373768703",
"payload": Object {
"body": "It should also be possible to reference by exact url: https://github.com/sourcecred/example-repo/issues/6",
"url": "https://github.com/sourcecred/example-repo/issues/2#issuecomment-373768703",
},
"rendered": <div>
type:
COMMENT
(details to be implemented)
</div>,
"title": "comment on #2: A referencing issue.",
"type": "COMMENT",
},
Object {
"id": "https://github.com/sourcecred/example-repo/issues/2#issuecomment-373768850",
"payload": Object {
"body": "We might also reference individual comments directly.
https://github.com/sourcecred/example-repo/issues/6#issuecomment-373768538",
"url": "https://github.com/sourcecred/example-repo/issues/2#issuecomment-373768850",
},
"rendered": <div>
type:
COMMENT
(details to be implemented)
</div>,
"title": "comment on #2: A referencing issue.",
"type": "COMMENT",
},
Object {
"id": "https://github.com/sourcecred/example-repo/issues/4",
"payload": Object {
"body": "Alas, its life as an open issue had only just begun.",
"number": 4,
"title": "A closed pull request",
"url": "https://github.com/sourcecred/example-repo/issues/4",
},
"rendered": <div>
type:
ISSUE
(details to be implemented)
</div>,
"title": "#4: A closed pull request",
"type": "ISSUE",
},
Object {
"id": "https://github.com/sourcecred/example-repo/issues/6",
"payload": Object {
"body": "This issue shall shortly have a few comments.",
"number": 6,
"title": "An issue with comments",
"url": "https://github.com/sourcecred/example-repo/issues/6",
},
"rendered": <div>
type:
ISSUE
(details to be implemented)
</div>,
"title": "#6: An issue with comments",
"type": "ISSUE",
},
Object {
"id": "https://github.com/sourcecred/example-repo/issues/6#issuecomment-373768442",
"payload": Object {
"body": "A wild COMMENT appeared!",
"url": "https://github.com/sourcecred/example-repo/issues/6#issuecomment-373768442",
},
"rendered": <div>
type:
COMMENT
(details to be implemented)
</div>,
"title": "comment on #6: An issue with comments",
"type": "COMMENT",
},
Object {
"id": "https://github.com/sourcecred/example-repo/issues/6#issuecomment-373768538",
"payload": Object {
"body": "And the maintainer said, \\"Let there be comments!\\"",
"url": "https://github.com/sourcecred/example-repo/issues/6#issuecomment-373768538",
},
"rendered": <div>
type:
COMMENT
(details to be implemented)
</div>,
"title": "comment on #6: An issue with comments",
"type": "COMMENT",
},
Object {
"id": "https://github.com/sourcecred/example-repo/issues/7",
"payload": Object {
"body": "Deal with this, naive string display algorithms!!!!!",
"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",
},
"rendered": <div>
type:
ISSUE
(details to be implemented)
</div>,
"title": "#7: An issue with an extremely long title, which even has a VerySuperFragicalisticialiManyCharacterUberLongTriplePlusGood word in it, and should really be truncated intelligently or something",
"type": "ISSUE",
},
Object {
"id": "https://github.com/sourcecred/example-repo/issues/8",
"payload": Object {
"body": "Issue with Unicode: ȴሲ𣐳楢👍 :heart: 𐤔𐤁𐤀𐤑𐤍𐤉𐤔𐤌𐤄𐤍𐤍 ❤️
Issue with Unicode: ȴሲ𣐳楢👍 :heart: 𐤔𐤁𐤀𐤑𐤍𐤉𐤔𐤌𐤄𐤍𐤍 ❤️",
"number": 8,
"title": "Issue with Unicode: ȴሲ𣐳楢👍 :heart: 𐤔𐤁𐤀𐤑𐤍𐤉𐤔𐤌𐤄𐤍𐤍 ❤️",
"url": "https://github.com/sourcecred/example-repo/issues/8",
},
"rendered": <div>
type:
ISSUE
(details to be implemented)
</div>,
"title": "#8: Issue with Unicode: ȴሲ𣐳楢👍 :heart: 𐤔𐤁𐤀𐤑𐤍𐤉𐤔𐤌𐤄𐤍𐤍 ❤️",
"type": "ISSUE",
},
Object {
"id": "https://github.com/sourcecred/example-repo/pull/3",
"payload": Object { "payload": Object {
"body": "Oh look, it's a pull request.", "body": "Oh look, it's a pull request.",
"number": 3, "number": 3,
@ -49,7 +187,21 @@ Array [
"type": "PULL_REQUEST", "type": "PULL_REQUEST",
}, },
Object { Object {
"id": "MDExOlB1bGxSZXF1ZXN0MTcxODg4NTIy", "id": "https://github.com/sourcecred/example-repo/pull/3#issuecomment-369162222",
"payload": Object {
"body": "It seems apropos to reference something from a pull request comment... eg: #2 ",
"url": "https://github.com/sourcecred/example-repo/pull/3#issuecomment-369162222",
},
"rendered": <div>
type:
COMMENT
(details to be implemented)
</div>,
"title": "comment on #3: Add README, merge via PR.",
"type": "COMMENT",
},
Object {
"id": "https://github.com/sourcecred/example-repo/pull/5",
"payload": Object { "payload": Object {
"body": "@wchargin could you please do the following: "body": "@wchargin could you please do the following:
- add a commit comment - add a commit comment
@ -69,78 +221,7 @@ Array [
"type": "PULL_REQUEST", "type": "PULL_REQUEST",
}, },
Object { Object {
"id": "MDEyOklzc3VlQ29tbWVudDM2OTE2MjIyMg==", "id": "https://github.com/sourcecred/example-repo/pull/5#discussion_r171460198",
"payload": Object {
"body": "It seems apropos to reference something from a pull request comment... eg: #2 ",
"url": "https://github.com/sourcecred/example-repo/pull/3#issuecomment-369162222",
},
"rendered": <div>
type:
COMMENT
(details to be implemented)
</div>,
"title": "comment on #3: Add README, merge via PR.",
"type": "COMMENT",
},
Object {
"id": "MDEyOklzc3VlQ29tbWVudDM3Mzc2ODQ0Mg==",
"payload": Object {
"body": "A wild COMMENT appeared!",
"url": "https://github.com/sourcecred/example-repo/issues/6#issuecomment-373768442",
},
"rendered": <div>
type:
COMMENT
(details to be implemented)
</div>,
"title": "comment on #6: An issue with comments",
"type": "COMMENT",
},
Object {
"id": "MDEyOklzc3VlQ29tbWVudDM3Mzc2ODUzOA==",
"payload": Object {
"body": "And the maintainer said, \\"Let there be comments!\\"",
"url": "https://github.com/sourcecred/example-repo/issues/6#issuecomment-373768538",
},
"rendered": <div>
type:
COMMENT
(details to be implemented)
</div>,
"title": "comment on #6: An issue with comments",
"type": "COMMENT",
},
Object {
"id": "MDEyOklzc3VlQ29tbWVudDM3Mzc2ODcwMw==",
"payload": Object {
"body": "It should also be possible to reference by exact url: https://github.com/sourcecred/example-repo/issues/6",
"url": "https://github.com/sourcecred/example-repo/issues/2#issuecomment-373768703",
},
"rendered": <div>
type:
COMMENT
(details to be implemented)
</div>,
"title": "comment on #2: A referencing issue.",
"type": "COMMENT",
},
Object {
"id": "MDEyOklzc3VlQ29tbWVudDM3Mzc2ODg1MA==",
"payload": Object {
"body": "We might also reference individual comments directly.
https://github.com/sourcecred/example-repo/issues/6#issuecomment-373768538",
"url": "https://github.com/sourcecred/example-repo/issues/2#issuecomment-373768850",
},
"rendered": <div>
type:
COMMENT
(details to be implemented)
</div>,
"title": "comment on #2: A referencing issue.",
"type": "COMMENT",
},
Object {
"id": "MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE3MTQ2MDE5OA==",
"payload": Object { "payload": Object {
"body": "seems a bit capricious", "body": "seems a bit capricious",
"url": "https://github.com/sourcecred/example-repo/pull/5#discussion_r171460198", "url": "https://github.com/sourcecred/example-repo/pull/5#discussion_r171460198",
@ -154,21 +235,37 @@ https://github.com/sourcecred/example-repo/issues/6#issuecomment-373768538",
"type": "PULL_REQUEST_REVIEW_COMMENT", "type": "PULL_REQUEST_REVIEW_COMMENT",
}, },
Object { Object {
"id": "MDQ6VXNlcjE0MDAwMjM=", "id": "https://github.com/sourcecred/example-repo/pull/5#pullrequestreview-100313899",
"payload": Object { "payload": Object {
"login": "decentralion", "body": "hmmm.jpg",
"url": "https://github.com/decentralion", "state": "CHANGES_REQUESTED",
"url": "https://github.com/sourcecred/example-repo/pull/5#pullrequestreview-100313899",
}, },
"rendered": <div> "rendered": <div>
type: type:
USER PULL_REQUEST_REVIEW
(details to be implemented) (details to be implemented)
</div>, </div>,
"title": "decentralion", "title": "review of #5: This pull request will be more contentious. I can feel it...",
"type": "USER", "type": "PULL_REQUEST_REVIEW",
}, },
Object { Object {
"id": "MDQ6VXNlcjQzMTc4MDY=", "id": "https://github.com/sourcecred/example-repo/pull/5#pullrequestreview-100314038",
"payload": Object {
"body": "I'm sold",
"state": "APPROVED",
"url": "https://github.com/sourcecred/example-repo/pull/5#pullrequestreview-100314038",
},
"rendered": <div>
type:
PULL_REQUEST_REVIEW
(details to be implemented)
</div>,
"title": "review of #5: This pull request will be more contentious. I can feel it...",
"type": "PULL_REQUEST_REVIEW",
},
Object {
"id": "https://github.com/wchargin",
"payload": Object { "payload": Object {
"login": "wchargin", "login": "wchargin",
"url": "https://github.com/wchargin", "url": "https://github.com/wchargin",
@ -181,102 +278,5 @@ https://github.com/sourcecred/example-repo/issues/6#issuecomment-373768538",
"title": "wchargin", "title": "wchargin",
"type": "USER", "type": "USER",
}, },
Object {
"id": "MDU6SXNzdWUzMDA5MzQ4MTg=",
"payload": Object {
"body": "This is just an example issue.",
"number": 1,
"title": "An example issue.",
"url": "https://github.com/sourcecred/example-repo/issues/1",
},
"rendered": <div>
type:
ISSUE
(details to be implemented)
</div>,
"title": "#1: An example issue.",
"type": "ISSUE",
},
Object {
"id": "MDU6SXNzdWUzMDA5MzQ5ODA=",
"payload": Object {
"body": "This issue references another issue, namely #1",
"number": 2,
"title": "A referencing issue.",
"url": "https://github.com/sourcecred/example-repo/issues/2",
},
"rendered": <div>
type:
ISSUE
(details to be implemented)
</div>,
"title": "#2: A referencing issue.",
"type": "ISSUE",
},
Object {
"id": "MDU6SXNzdWUzMDA5MzYzNzQ=",
"payload": Object {
"body": "Alas, its life as an open issue had only just begun.",
"number": 4,
"title": "A closed pull request",
"url": "https://github.com/sourcecred/example-repo/issues/4",
},
"rendered": <div>
type:
ISSUE
(details to be implemented)
</div>,
"title": "#4: A closed pull request",
"type": "ISSUE",
},
Object {
"id": "MDU6SXNzdWUzMDU5OTM3NzM=",
"payload": Object {
"body": "This issue shall shortly have a few comments.",
"number": 6,
"title": "An issue with comments",
"url": "https://github.com/sourcecred/example-repo/issues/6",
},
"rendered": <div>
type:
ISSUE
(details to be implemented)
</div>,
"title": "#6: An issue with comments",
"type": "ISSUE",
},
Object {
"id": "MDU6SXNzdWUzMDY5ODM1NTI=",
"payload": Object {
"body": "Deal with this, naive string display algorithms!!!!!",
"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",
},
"rendered": <div>
type:
ISSUE
(details to be implemented)
</div>,
"title": "#7: An issue with an extremely long title, which even has a VerySuperFragicalisticialiManyCharacterUberLongTriplePlusGood word in it, and should really be truncated intelligently or something",
"type": "ISSUE",
},
Object {
"id": "MDU6SXNzdWUzMDY5ODUzNjc=",
"payload": Object {
"body": "Issue with Unicode: ȴሲ𣐳楢👍 :heart: 𐤔𐤁𐤀𐤑𐤍𐤉𐤔𐤌𐤄𐤍𐤍 ❤️
Issue with Unicode: ȴሲ𣐳楢👍 :heart: 𐤔𐤁𐤀𐤑𐤍𐤉𐤔𐤌𐤄𐤍𐤍 ❤️",
"number": 8,
"title": "Issue with Unicode: ȴሲ𣐳楢👍 :heart: 𐤔𐤁𐤀𐤑𐤍𐤉𐤔𐤌𐤄𐤍𐤍 ❤️",
"url": "https://github.com/sourcecred/example-repo/issues/8",
},
"rendered": <div>
type:
ISSUE
(details to be implemented)
</div>,
"title": "#8: Issue with Unicode: ȴሲ𣐳楢👍 :heart: 𐤔𐤁𐤀𐤑𐤍𐤉𐤔𐤌𐤄𐤍𐤍 ❤️",
"type": "ISSUE",
},
] ]
`; `;

File diff suppressed because it is too large Load Diff

View File

@ -39,12 +39,12 @@ export class GithubParser {
this.graph = new Graph(); this.graph = new Graph();
} }
makeNodeAddress(type: NodeType, id: string): Address { makeNodeAddress(type: NodeType, url: string): Address {
return { return {
pluginName: PLUGIN_NAME, pluginName: PLUGIN_NAME,
repositoryName: this.repositoryName, repositoryName: this.repositoryName,
type, type,
id, id: url,
}; };
} }
@ -91,7 +91,7 @@ export class GithubParser {
} }
const authorNode: Node<AuthorNodePayload> = { const authorNode: Node<AuthorNodePayload> = {
address: this.makeNodeAddress(authorType, authorJson.id), address: this.makeNodeAddress(authorType, authorJson.url),
payload: authorPayload, payload: authorPayload,
}; };
this.graph.addNode(authorNode); this.graph.addNode(authorNode);
@ -139,7 +139,7 @@ export class GithubParser {
const commentNode: Node< const commentNode: Node<
CommentNodePayload | PullRequestReviewCommentNodePayload CommentNodePayload | PullRequestReviewCommentNodePayload
> = { > = {
address: this.makeNodeAddress(commentType, commentJson.id), address: this.makeNodeAddress(commentType, commentJson.url),
payload: commentNodePayload, payload: commentNodePayload,
}; };
this.graph.addNode(commentNode); this.graph.addNode(commentNode);
@ -179,7 +179,7 @@ export class GithubParser {
body: issueJson.body, body: issueJson.body,
}; };
const issueNode: Node<IssueNodePayload> = { const issueNode: Node<IssueNodePayload> = {
address: this.makeNodeAddress("ISSUE", issueJson.id), address: this.makeNodeAddress("ISSUE", issueJson.url),
payload: issuePayload, payload: issuePayload,
}; };
this.graph.addNode(issueNode); this.graph.addNode(issueNode);
@ -197,7 +197,7 @@ export class GithubParser {
body: prJson.body, body: prJson.body,
}; };
const pullRequestNode: Node<PullRequestNodePayload> = { const pullRequestNode: Node<PullRequestNodePayload> = {
address: this.makeNodeAddress("PULL_REQUEST", prJson.id), address: this.makeNodeAddress("PULL_REQUEST", prJson.url),
payload: pullRequestPayload, payload: pullRequestPayload,
}; };
this.graph.addNode(pullRequestNode); this.graph.addNode(pullRequestNode);
@ -220,7 +220,7 @@ export class GithubParser {
body: reviewJson.body, body: reviewJson.body,
}; };
const reviewNode: Node<PullRequestReviewNodePayload> = { const reviewNode: Node<PullRequestReviewNodePayload> = {
address: this.makeNodeAddress("PULL_REQUEST_REVIEW", reviewJson.id), address: this.makeNodeAddress("PULL_REQUEST_REVIEW", reviewJson.url),
payload: reviewPayload, payload: reviewPayload,
}; };
this.graph.addNode(reviewNode); this.graph.addNode(reviewNode);