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.
This commit is contained in:
Dandelion Mané 2018-06-28 14:03:45 -07:00 committed by GitHub
parent 1421148a6d
commit 38942d1f7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 342 additions and 0 deletions

View File

@ -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 [

View File

@ -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) {