From 5c44dd0373e27a88f648d7aa571c70156a09fa5c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dandelion=20Man=C3=A9?=
Date: Thu, 10 May 2018 11:24:24 -0700
Subject: [PATCH] GH Porcelain: Move `authors` top-level Porcelain (#254)
Currently, the `authors` method is attached at the Repository level.
This is incorrect; it actually finds all the authors in the graph, not
all the authors of that repository. This commit moves the method to the
correct class.
Test plan: This function is only used in test code. The tests still
pass.
---
src/plugins/github/porcelain.js | 12 ++++++------
src/plugins/github/porcelain.test.js | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/plugins/github/porcelain.js b/src/plugins/github/porcelain.js
index fafeea1..bcca92a 100644
--- a/src/plugins/github/porcelain.js
+++ b/src/plugins/github/porcelain.js
@@ -133,6 +133,12 @@ export class Porcelain {
}
return repo[0];
}
+
+ authors(): Author[] {
+ return this.graph
+ .nodes({type: AUTHOR_NODE_TYPE})
+ .map((n) => new Author(this.graph, n.address));
+ }
}
class GithubEntity {
@@ -200,12 +206,6 @@ export class Repository extends GithubEntity {
.nodes({type: PULL_REQUEST_NODE_TYPE})
.map((n) => new PullRequest(this.graph, n.address));
}
-
- authors(): Author[] {
- return this.graph
- .nodes({type: AUTHOR_NODE_TYPE})
- .map((n) => new Author(this.graph, n.address));
- }
}
class Post<
diff --git a/src/plugins/github/porcelain.test.js b/src/plugins/github/porcelain.test.js
index f80bd3c..f16d5b7 100644
--- a/src/plugins/github/porcelain.test.js
+++ b/src/plugins/github/porcelain.test.js
@@ -150,7 +150,7 @@ describe("GitHub porcelain", () => {
});
it("Authors", () => {
- const authors = repo.authors();
+ const authors = porcelain.authors();
// So we don't need to manually update the test if a new person posts
expect(authors.length).toMatchSnapshot();