diff --git a/CHANGELOG.md b/CHANGELOG.md index 01a06fe..b32e614 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## [Unreleased] +- Detect references to commits (#833) - Detect references in commit messages (#829) - Add commit authorship to the graph (#826) - Add `MentionsAuthor` edges to the graph (#808) diff --git a/src/plugins/github/__snapshots__/createGraph.test.js.snap b/src/plugins/github/__snapshots__/createGraph.test.js.snap index f4cea74..bdbae46 100644 --- a/src/plugins/github/__snapshots__/createGraph.test.js.snap +++ b/src/plugins/github/__snapshots__/createGraph.test.js.snap @@ -1669,6 +1669,48 @@ Array [ "dstIndex": 30, "srcIndex": 26, }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "sourcecred", + "github", + "ISSUE", + "sourcecred", + "example-github", + "12", + "4", + "sourcecred", + "git", + "COMMIT", + "ec91adb718a6045b492303f00d8e8beb957dc780", + ], + "dstIndex": 4, + "srcIndex": 28, + }, + Object { + "address": Array [ + "sourcecred", + "github", + "REFERENCES", + "6", + "sourcecred", + "github", + "ISSUE", + "sourcecred", + "example-github", + "12", + "4", + "sourcecred", + "git", + "COMMIT", + "ecc889dc94cf6da17ae6eab5bb7b7155f577519d", + ], + "dstIndex": 5, + "srcIndex": 28, + }, Object { "address": Array [ "sourcecred", diff --git a/src/plugins/github/__snapshots__/relationalView.test.js.snap b/src/plugins/github/__snapshots__/relationalView.test.js.snap index d5c1c6c..c7233a9 100644 --- a/src/plugins/github/__snapshots__/relationalView.test.js.snap +++ b/src/plugins/github/__snapshots__/relationalView.test.js.snap @@ -299,6 +299,14 @@ Array [ "from": "https://github.com/sourcecred/example-github/issues/10", "to": "https://github.com/sourcecred/example-github/issues/2", }, + Object { + "from": "https://github.com/sourcecred/example-github/issues/12", + "to": "https://github.com/sourcecred/example-github/commit/ec91adb718a6045b492303f00d8e8beb957dc780", + }, + Object { + "from": "https://github.com/sourcecred/example-github/issues/12", + "to": "https://github.com/sourcecred/example-github/commit/ecc889dc94cf6da17ae6eab5bb7b7155f577519d", + }, Object { "from": "https://github.com/sourcecred/example-github/pull/5", "to": "https://github.com/wchargin", diff --git a/src/plugins/github/graphView.js b/src/plugins/github/graphView.js index 30e6519..11a7cd0 100644 --- a/src/plugins/github/graphView.js +++ b/src/plugins/github/graphView.js @@ -217,6 +217,7 @@ export class GraphView { GN.Prefix.review, GN.Prefix.comment, GN.Prefix.userlike, + GitNode.Prefix.commit, ] ), srcAccessor: (x) => GN.toRaw((x: any).referrer), diff --git a/src/plugins/github/nodes.js b/src/plugins/github/nodes.js index b1697bd..ee6f4ad 100644 --- a/src/plugins/github/nodes.js +++ b/src/plugins/github/nodes.js @@ -102,6 +102,7 @@ export type ReferentAddress = | PullAddress | ReviewAddress | CommentAddress + | GitNode.CommitAddress | UserlikeAddress; // Each of these types is structurally the child of some diff --git a/src/plugins/github/relationalView.js b/src/plugins/github/relationalView.js index 55d990e..fead875 100644 --- a/src/plugins/github/relationalView.js +++ b/src/plugins/github/relationalView.js @@ -211,6 +211,7 @@ export class RelationalView { yield* this.pulls(); yield* this.reviews(); yield* this.comments(); + yield* this.commits(); yield* this.userlikes(); } @@ -463,6 +464,9 @@ export class RelationalView { a ); } + if (e instanceof Commit) { + refToAddress.set(e.address().hash, a); + } } for (const e of this.textContentEntities()) { const srcAddress = e.address(); @@ -589,6 +593,9 @@ export class RelationalView { case "COMMENT": entity = this.comment(address); break; + case "COMMIT": + entity = this.commit(address); + break; case "USERLIKE": entity = this.userlike(address); break; @@ -882,6 +889,9 @@ export class Commit extends _Entity { references(): Iterator { return this._view._references(this); } + referencedBy(): Iterator { + return this._view._referencedBy(this); + } } type UserlikeEntry = {| @@ -959,7 +969,14 @@ export type AuthoredEntity = Issue | Pull | Review | Comment | Commit; export type TextContentEntity = Issue | Pull | Review | Comment | Commit; export type ParentEntity = Repo | Issue | Pull | Review; export type ChildEntity = Issue | Pull | Review | Comment; -export type ReferentEntity = Repo | Issue | Pull | Review | Comment | Userlike; +export type ReferentEntity = + | Repo + | Issue + | Pull + | Review + | Comment + | Commit + | Userlike; export opaque type AddressEntryMapJSON = {[N.RawAddress]: T}; export opaque type RelationalViewJSON = Compatible<{|