Skip to content

Commit

Permalink
fix: renamed labels break the bot
Browse files Browse the repository at this point in the history
Closes #20
  • Loading branch information
kellertk committed Apr 24, 2020
1 parent 8f2918f commit fdc9630
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,16 @@ module.exports.getLastLabelTime = (events, label) => {
const searchLabelEvents = labelEvents.filter((event) => {
return event.label.name === label;
});
searchLabelEvents.sort(revCompareEventsByDate);
return Date.parse(searchLabelEvents[0].created_at);
if (searchLabelEvents.length > 0) {
searchLabelEvents.sort(revCompareEventsByDate);
return Date.parse(searchLabelEvents[0].created_at);
} else {
log.warn(
`Could not find a ${label} label event in this issue's timeline. Was this issue renamed?`
);
log.warn('Defaulting the label time to now so we skip over this issue');
return new Date(Date.now());
}
};

/**
Expand Down

0 comments on commit fdc9630

Please sign in to comment.