diff --git a/utils/issue-format-bot/lib/issueedit.js b/utils/issue-format-bot/lib/issueedit.js index e7984364b9b0..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) { @@ -20,6 +23,12 @@ module.exports = function(robot, alexa) { return; } + const createdAt = new Date(context.payload.issue.created_at); + if (createdAt <= botStartDate) { + robot.log('Ignoring event for a legacy, pre-bot issue.'); + return; + } + const data = parse(context.payload.issue.body); // Check if the data is problematic 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) {