From 24a7547e16a1af023320bff66a5ff58ad7b04391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dandelion=20Man=C3=A9?= Date: Fri, 22 Jun 2018 12:12:08 -0700 Subject: [PATCH] Use Git Commit type in GitHub mergedAs edge (#407) Test plan: `yarn travis` passes --- src/v3/plugins/github/__snapshots__/edges.test.js.snap | 3 ++- src/v3/plugins/github/edges.js | 6 +++--- src/v3/plugins/github/edges.test.js | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/v3/plugins/github/__snapshots__/edges.test.js.snap b/src/v3/plugins/github/__snapshots__/edges.test.js.snap index 86a6e46..d6dd066 100644 --- a/src/v3/plugins/github/__snapshots__/edges.test.js.snap +++ b/src/v3/plugins/github/__snapshots__/edges.test.js.snap @@ -83,8 +83,9 @@ Object { "5", ], "dstParts": Array [ + "sourcecred", "git", - "commit", + "COMMIT", "123", ], "srcParts": Array [ diff --git a/src/v3/plugins/github/edges.js b/src/v3/plugins/github/edges.js index 8ef61df..6495967 100644 --- a/src/v3/plugins/github/edges.js +++ b/src/v3/plugins/github/edges.js @@ -3,11 +3,11 @@ import { type Edge, type EdgeAddressT, - type NodeAddressT, EdgeAddress, NodeAddress, } from "../../core/graph"; import * as GithubNode from "./nodes"; +import * as GitNode from "../git/nodes"; export opaque type RawAddress: EdgeAddressT = EdgeAddressT; @@ -65,11 +65,11 @@ export const createEdge = Object.freeze({ }), mergedAs: ( pull: GithubNode.PullAddress, - commitAddress: NodeAddressT /* TODO: Make this a Git commit node address. */ + commit: GitNode.CommitAddress ): Edge => ({ address: toRaw({type: MERGED_AS_TYPE, pull}), src: GithubNode.toRaw(pull), - dst: commitAddress, + dst: GitNode.toRaw(commit), }), hasParent: ( child: GithubNode.ChildAddress, diff --git a/src/v3/plugins/github/edges.test.js b/src/v3/plugins/github/edges.test.js index 38e9faf..069f922 100644 --- a/src/v3/plugins/github/edges.test.js +++ b/src/v3/plugins/github/edges.test.js @@ -1,9 +1,10 @@ // @flow -import {type EdgeAddressT, NodeAddress, edgeToParts} from "../../core/graph"; +import {type EdgeAddressT, edgeToParts} from "../../core/graph"; import {createEdge, fromRaw, toRaw} from "./edges"; import * as GE from "./edges"; import * as GN from "./nodes"; +import {COMMIT_TYPE} from "../git/nodes"; describe("plugins/github/edges", () => { const nodeExamples = { @@ -45,8 +46,8 @@ describe("plugins/github/edges", () => { authors: () => createEdge.authors(nodeExamples.user(), nodeExamples.issue()), mergedAs: () => { - const commitAddress = NodeAddress.fromParts(["git", "commit", "123"]); - return createEdge.mergedAs(nodeExamples.pull(), commitAddress); + const commit = {type: COMMIT_TYPE, hash: "123"}; + return createEdge.mergedAs(nodeExamples.pull(), commit); }, hasParent: () => createEdge.hasParent(nodeExamples.reviewComment(), nodeExamples.review()),