From 38942d1f7b9b0f95d4cc0ac95622c04cac5a4c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dandelion=20Man=C3=A9?= Date: Thu, 28 Jun 2018 14:03:45 -0700 Subject: [PATCH] Add references to the GitHub graph (#434) This is a very simple extension of #431 to use the new reference detection logic added in #429. Test plan: Inspect snapshot change for plausibility. Note that the snapshot adds exactly 16 reference edges, which is the same as the number of references in the reference snapshot test. --- .../__snapshots__/createGraph.test.js.snap | 334 ++++++++++++++++++ src/v3/plugins/github/createGraph.js | 8 + 2 files changed, 342 insertions(+) diff --git a/src/v3/plugins/github/__snapshots__/createGraph.test.js.snap b/src/v3/plugins/github/__snapshots__/createGraph.test.js.snap index 71e982e..032b142 100644 --- a/src/v3/plugins/github/__snapshots__/createGraph.test.js.snap +++ b/src/v3/plugins/github/__snapshots__/createGraph.test.js.snap @@ -873,6 +873,340 @@ Array [ "dstIndex": 1, "srcIndex": 23, }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "4", + "ISSUE", + "sourcecred", + "example-github", + "2", + "4", + "ISSUE", + "sourcecred", + "example-github", + "1", + ], + "dstIndex": 16, + "srcIndex": 17, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "4", + "PULL", + "sourcecred", + "example-github", + "5", + "2", + "USERLIKE", + "wchargin", + ], + "dstIndex": 29, + "srcIndex": 23, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "4", + "PULL", + "sourcecred", + "example-github", + "9", + "2", + "USERLIKE", + "wchargin", + ], + "dstIndex": 29, + "srcIndex": 24, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "COMMENT", + "ISSUE", + "sourcecred", + "example-github", + "2", + "373768703", + "4", + "ISSUE", + "sourcecred", + "example-github", + "6", + ], + "dstIndex": 19, + "srcIndex": 2, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "COMMENT", + "ISSUE", + "sourcecred", + "example-github", + "2", + "373768850", + "6", + "COMMENT", + "ISSUE", + "sourcecred", + "example-github", + "6", + "373768538", + ], + "dstIndex": 11, + "srcIndex": 3, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "COMMENT", + "ISSUE", + "sourcecred", + "example-github", + "2", + "385576185", + "4", + "PULL", + "sourcecred", + "example-github", + "5", + ], + "dstIndex": 23, + "srcIndex": 4, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "COMMENT", + "ISSUE", + "sourcecred", + "example-github", + "2", + "385576220", + "5", + "REVIEW", + "sourcecred", + "example-github", + "5", + "100313899", + ], + "dstIndex": 26, + "srcIndex": 5, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "COMMENT", + "ISSUE", + "sourcecred", + "example-github", + "2", + "385576248", + "7", + "COMMENT", + "REVIEW", + "sourcecred", + "example-github", + "5", + "100313899", + "171460198", + ], + "dstIndex": 15, + "srcIndex": 6, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "COMMENT", + "ISSUE", + "sourcecred", + "example-github", + "2", + "385576273", + "2", + "USERLIKE", + "wchargin", + ], + "dstIndex": 29, + "srcIndex": 7, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "COMMENT", + "ISSUE", + "sourcecred", + "example-github", + "2", + "385576920", + "4", + "ISSUE", + "sourcecred", + "example-github", + "1", + ], + "dstIndex": 16, + "srcIndex": 8, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "COMMENT", + "ISSUE", + "sourcecred", + "example-github", + "2", + "385576920", + "4", + "ISSUE", + "sourcecred", + "example-github", + "2", + ], + "dstIndex": 17, + "srcIndex": 8, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "COMMENT", + "ISSUE", + "sourcecred", + "example-github", + "2", + "385576920", + "4", + "PULL", + "sourcecred", + "example-github", + "3", + ], + "dstIndex": 22, + "srcIndex": 8, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "COMMENT", + "ISSUE", + "sourcecred", + "example-github", + "2", + "385576920", + "5", + "REVIEW", + "sourcecred", + "example-github", + "5", + "100313899", + ], + "dstIndex": 26, + "srcIndex": 8, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "COMMENT", + "ISSUE", + "sourcecred", + "example-github", + "2", + "385576920", + "7", + "COMMENT", + "REVIEW", + "sourcecred", + "example-github", + "5", + "100313899", + "171460198", + ], + "dstIndex": 15, + "srcIndex": 8, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "COMMENT", + "ISSUE", + "sourcecred", + "example-github", + "6", + "385223316", + "4", + "ISSUE", + "sourcecred", + "example-github", + "2", + ], + "dstIndex": 17, + "srcIndex": 12, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "COMMENT", + "PULL", + "sourcecred", + "example-github", + "3", + "369162222", + "4", + "ISSUE", + "sourcecred", + "example-github", + "2", + ], + "dstIndex": 17, + "srcIndex": 13, + }, ], "nodes": Array [ Array [ diff --git a/src/v3/plugins/github/createGraph.js b/src/v3/plugins/github/createGraph.js index a1d9fb8..3d2b74b 100644 --- a/src/v3/plugins/github/createGraph.js +++ b/src/v3/plugins/github/createGraph.js @@ -39,6 +39,14 @@ class GraphCreator { this.graph.addEdge(createEdge.mergedAs(pull.address(), commit)); } } + + for (const referrer of view.textContentEntities()) { + for (const referent of referrer.references()) { + this.graph.addEdge( + createEdge.references(referrer.address(), referent.address()) + ); + } + } } addNode(addr: N.StructuredAddress) {