feat: fetch data for prs that need retest

This commit is contained in:
2018-10-17 15:56:11 -07:00
parent b6b5c27ffc
commit d1cfd7c20b
8 changed files with 164 additions and 4 deletions

23
src/lib/get_comments.mjs Normal file
View File

@@ -0,0 +1,23 @@
export default async function getEvents(repo, { body, actor } = {}) {
const { items: events } = await repo.events.fetch();
return events
.map(comment => {
// only comments created by specific user
if (comment.type !== 'IssueCommentEvent') return false;
if (comment.payload.action !== 'created') return false;
if (comment.actor.login !== actor) return false;
if (body && !body.test(comment.payload.comment.body)) return false;
return {
id: comment.id,
number: comment.payload.issue.number,
owner: comment.payload.issue.user.login,
labels: comment.payload.issue.labels.map(label => label.name),
comment_id: comment.payload.comment.id,
comment_author: comment.payload.comment.user.login,
comment_body: comment.payload.comment.body,
};
})
.filter(Boolean);
}