From a29eaa164bd412a81956ed59f7f80322fb194a14 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Tue, 29 Aug 2017 08:46:22 -0500 Subject: [PATCH] Skip unfreeze if no freeze comment found Fixes #8 --- index.js | 2 +- lib/freeze.js | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 84f3fd7..24a452b 100644 --- a/index.js +++ b/index.js @@ -49,7 +49,7 @@ module.exports = robot => { context.github.issues.getComments(githubHelper.parseCommentURL(issue.comments_url)).then(resp => { return freeze.getLastFreeze(resp.data); }).then(lastFreezeComment => { - if (freeze.unfreezable(lastFreezeComment)) { + if (lastFreezeComment && freeze.unfreezable(lastFreezeComment)) { freeze.unfreeze(issue, formatParser.propFromComment(lastFreezeComment)); } }); diff --git a/lib/freeze.js b/lib/freeze.js index 05f321c..0f58dca 100644 --- a/lib/freeze.js +++ b/lib/freeze.js @@ -32,15 +32,9 @@ module.exports = class Freeze { } getLastFreeze(comments) { - let mainComment = {}; - comments.reverse().some(comment => { - if (comment.user.login === this.config.probotUsername) { - mainComment = comment; - return true; - } - return false; + return comments.reverse().find(comment => { + return comment.user.login === this.config.probotUsername; }); - return mainComment; } freeze(context, props) {