diff --git a/src/plugins/github/__snapshots__/createGraph.test.js.snap b/src/plugins/github/__snapshots__/createGraph.test.js.snap index 0fd248b..2812955 100644 --- a/src/plugins/github/__snapshots__/createGraph.test.js.snap +++ b/src/plugins/github/__snapshots__/createGraph.test.js.snap @@ -15,7 +15,7 @@ Array [ "AUTHORS", "3", "USERLIKE", - "USER", + "BOT", "credbot", "6", "COMMENT", @@ -1633,7 +1633,7 @@ Array [ "sourcecred", "github", "USERLIKE", - "USER", + "BOT", "credbot", ], Array [ diff --git a/src/plugins/github/bots.js b/src/plugins/github/bots.js new file mode 100644 index 0000000..583922a --- /dev/null +++ b/src/plugins/github/bots.js @@ -0,0 +1,19 @@ +// @flow + +// TODO(#638): Allow projects to specify bots via configuration, +// rather than depending on this single souce of truth +export function botSet(): Set { + return new Set([ + "credbot", + "facebook-github-bot", + "gitcoinbot", + "googlebot", + "greenkeeper", + "greenkeeperio-bot", + "metamaskbot", + "nodejs-github-bot", + "stickler-ci", + "tensorflow-jenkins", + "tensorflowbutler", + ]); +} diff --git a/src/plugins/github/relationalView.js b/src/plugins/github/relationalView.js index c6cd823..d062e86 100644 --- a/src/plugins/github/relationalView.js +++ b/src/plugins/github/relationalView.js @@ -25,6 +25,7 @@ import type { } from "./graphql"; import * as GitNode from "../git/nodes"; import * as MapUtil from "../../util/map"; +import {botSet} from "./bots"; import { reviewUrlToId, @@ -342,11 +343,12 @@ export class RelationalView { if (json == null) { return []; } else { + const login = json.login; + const subtype = botSet().has(login) ? N.BOT_SUBTYPE : N.USER_SUBTYPE; const address: UserlikeAddress = { type: N.USERLIKE_TYPE, - // TODO: Detect bots and give them a different subtype (#696) - subtype: N.USER_SUBTYPE, - login: json.login, + subtype, + login, }; const entry: UserlikeEntry = {address, url: json.url}; this._userlikes.set(N.toRaw(address), entry);