From 546fa31617cf9800c50cdb54b5169632aab24aa9 Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Thu, 2 Nov 2017 01:10:47 -0400 Subject: [PATCH 1/3] Ignore edits to issues predating the bot --- utils/issue-format-bot/lib/issueedit.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utils/issue-format-bot/lib/issueedit.js b/utils/issue-format-bot/lib/issueedit.js index e7984364b9b0..8facbf492dbb 100644 --- a/utils/issue-format-bot/lib/issueedit.js +++ b/utils/issue-format-bot/lib/issueedit.js @@ -20,6 +20,13 @@ module.exports = function(robot, alexa) { return; } + const createdAt = new Date(context.payload.issue.created_at); + // September 25th, 2017 + if (createdAt.getFullYear() <= 2017 && createdAt.getMonth() <= 8 && createdAt.getDate() <= 25) { + robot.log('Ignoring event for a legacy, pre-bot issue.'); + return; + } + const data = parse(context.payload.issue.body); // Check if the data is problematic From 1fb544599439da2e8410dcb46dd6d1c83a39c2f4 Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Thu, 2 Nov 2017 14:51:35 -0400 Subject: [PATCH 2/3] Fix date comparision for legacy issues --- utils/issue-format-bot/lib/issueedit.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/issue-format-bot/lib/issueedit.js b/utils/issue-format-bot/lib/issueedit.js index 8facbf492dbb..0ec12c42d7f2 100644 --- a/utils/issue-format-bot/lib/issueedit.js +++ b/utils/issue-format-bot/lib/issueedit.js @@ -7,6 +7,9 @@ const parse = require('./parse'), labeler = require('./labeler'), _ = require('lodash'); +// We do this outside the event handler to avoid setting up and tearing down this object each time a hook is received +const botStartDate = new Date('2018-09-25'); + // TODO make this share more with newissue.js? module.exports = function(robot, alexa) { @@ -21,8 +24,7 @@ module.exports = function(robot, alexa) { } const createdAt = new Date(context.payload.issue.created_at); - // September 25th, 2017 - if (createdAt.getFullYear() <= 2017 && createdAt.getMonth() <= 8 && createdAt.getDate() <= 25) { + if (createdAt <= botStartDate) { robot.log('Ignoring event for a legacy, pre-bot issue.'); return; } From d7af40a8c0e9caa705fc4b2d0473e03f56dabb3e Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Thu, 2 Nov 2017 15:01:32 -0400 Subject: [PATCH 3/3] Use a more precise assertion --- utils/issue-format-bot/test/labeler-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/issue-format-bot/test/labeler-test.js b/utils/issue-format-bot/test/labeler-test.js index 0172b7dc8d43..5f494f517d14 100644 --- a/utils/issue-format-bot/test/labeler-test.js +++ b/utils/issue-format-bot/test/labeler-test.js @@ -37,7 +37,7 @@ function resetSpies(context) { } function addLabelsCalledOnce(err, context) { - assert.ok(context.github.issues.addLabels.calledOnce); + assert.isTrue(context.github.issues.addLabels.calledOnce); } function assertWhichLabel(label) {