Add commit authorship to the graph (#826)

In #824, we loaded every commit in the default branch's history into the
GitHub relational view, along with authorship info. This commit actually
uses that authorship info to create AUTHORS edges from the commit to the
user that authored it (whenever possible).

The implementation is quite simple: we just need to yield the commits
when we yield all the authored entities, so that we will process their
authors and add them to the graph. Also, I updated the invariant
declarations in `graphView.js`, and corrected a type signature so that the
new invariants would typecheck.

Test plan: The snapshot update shows that commits are being added to the
graph appropriately. Observe that commits which do not have a valid
GitHub user as their author do not correspond to edges in the graph.
See [example].

This is basically a solution to #815, but I'll defer closing that issue
until I've added a few more features, like reference detection.

[example]: 6bd1b4c0b7
This commit is contained in:
Dandelion Mané 2018-09-13 14:19:37 -07:00 committed by GitHub
parent 4ad9fcf259
commit c68cb29769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 111 additions and 3 deletions

View File

@ -1,6 +1,7 @@
# Changelog
## [Unreleased]
- Add commit authorship to the graph (#826)
- Add `MentionsAuthor` edges to the graph (#808)
<!-- Please add new entries to the _top_ of this section. -->

View File

@ -8,6 +8,26 @@ Array [
},
Object {
"edges": Array [
Object {
"address": Array [
"sourcecred",
"github",
"AUTHORS",
"5",
"sourcecred",
"github",
"USERLIKE",
"BOT",
"credbot",
"4",
"sourcecred",
"git",
"COMMIT",
"c430bd74455105f77215ece51945094ceeee6c86",
],
"dstIndex": 3,
"srcIndex": 39,
},
Object {
"address": Array [
"sourcecred",
@ -32,6 +52,86 @@ Array [
"dstIndex": 21,
"srcIndex": 39,
},
Object {
"address": Array [
"sourcecred",
"github",
"AUTHORS",
"5",
"sourcecred",
"github",
"USERLIKE",
"USER",
"decentralion",
"4",
"sourcecred",
"git",
"COMMIT",
"0a223346b4e6dec0127b1e6aa892c4ee0424b66a",
],
"dstIndex": 0,
"srcIndex": 40,
},
Object {
"address": Array [
"sourcecred",
"github",
"AUTHORS",
"5",
"sourcecred",
"github",
"USERLIKE",
"USER",
"decentralion",
"4",
"sourcecred",
"git",
"COMMIT",
"6d5b3aa31ebb68a06ceb46bbd6cf49b6ccd6f5e6",
],
"dstIndex": 2,
"srcIndex": 40,
},
Object {
"address": Array [
"sourcecred",
"github",
"AUTHORS",
"5",
"sourcecred",
"github",
"USERLIKE",
"USER",
"decentralion",
"4",
"sourcecred",
"git",
"COMMIT",
"ec91adb718a6045b492303f00d8e8beb957dc780",
],
"dstIndex": 4,
"srcIndex": 40,
},
Object {
"address": Array [
"sourcecred",
"github",
"AUTHORS",
"5",
"sourcecred",
"github",
"USERLIKE",
"USER",
"decentralion",
"4",
"sourcecred",
"git",
"COMMIT",
"ecc889dc94cf6da17ae6eab5bb7b7155f577519d",
],
"dstIndex": 5,
"srcIndex": 40,
},
Object {
"address": Array [
"sourcecred",

View File

@ -164,8 +164,8 @@ export class GraphView {
+dstPrefix: NodeAddressT,
|};
function homProduct(
srcPrefixes: GN.RawAddress[],
dstPrefixes: GN.RawAddress[]
srcPrefixes: NodeAddressT[],
dstPrefixes: NodeAddressT[]
): Hom[] {
const result = [];
for (const srcPrefix of srcPrefixes) {
@ -224,7 +224,13 @@ export class GraphView {
[GE.AUTHORS_TYPE]: {
homs: homProduct(
[GN.Prefix.userlike],
[GN.Prefix.issue, GN.Prefix.review, GN.Prefix.pull, GN.Prefix.comment]
[
GN.Prefix.issue,
GN.Prefix.review,
GN.Prefix.pull,
GN.Prefix.comment,
GitNode.Prefix.commit,
]
),
srcAccessor: (x) => GN.toRaw((x: any).author),
dstAccessor: (x) => GN.toRaw((x: any).content),

View File

@ -234,6 +234,7 @@ export class RelationalView {
yield* this.pulls();
yield* this.reviews();
yield* this.comments();
yield* this.commits();
}
*entities(): Iterator<Entity> {