Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.

Ignore edits to issues predating the bot - #13460

Merged
Hainish merged 3 commits into
EFForg:masterfrom
strugee:fix-date-ignore-code
Nov 2, 2017
Merged

Hainish merged 3 commits into
EFForg:masterfrom
strugee:fix-date-ignore-code

Conversation

@strugee

@strugee strugee commented Nov 2, 2017

Copy link
Copy Markdown
Contributor

No description provided.

@strugee

strugee commented Nov 2, 2017

Copy link
Copy Markdown
Contributor Author

Should fix the scenario described in #10843 (comment).

@strugee

strugee commented Nov 2, 2017

Copy link
Copy Markdown
Contributor Author

/cc @Hainish @koops76

Comment thread utils/issue-format-bot/lib/issueedit.js Outdated

const createdAt = new Date(context.payload.issue.created_at);
// September 25th, 2017
if (createdAt.getFullYear() <= 2017 && createdAt.getMonth() <= 8 && createdAt.getDate() <= 25) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conditional will fail for an issue created in September, 2016.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cleanest way to do this without a long conditional is probably formatted string comparison. Munge createdAt into YYYY-MM-DD format, then compare it to "2017-08-25"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we compare Dates directly, or at least by conversion to timestamps?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hainish Better way is to compare dates directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hainish nice catch. Will push a fix based on #13460 (comment)

Comment thread utils/issue-format-bot/lib/issueedit.js Outdated

const createdAt = new Date(context.payload.issue.created_at);
// September 25th, 2017
if (createdAt.getFullYear() <= 2017 && createdAt.getMonth() <= 8 && createdAt.getDate() <= 25) {

@ghost ghost Nov 2, 2017 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const botCreatedDate = new Date(2017, 10, 25)
if (createdAt <= botCreatedDate) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks! I had no idea you could compare Dates like this; I was gonna compare Unix timestamps.

@strugee
strugee force-pushed the fix-date-ignore-code branch from b6232e9 to 1fb5445 Compare November 2, 2017 18:52
@strugee

strugee commented Nov 2, 2017

Copy link
Copy Markdown
Contributor Author

Fixed the date comparison and rebased on master.

@strugee

strugee commented Nov 2, 2017

Copy link
Copy Markdown
Contributor Author

Also pushed an unrelated test suite improvement that didn't seem worth sending a separate PR for.

@strugee strugee mentioned this pull request Nov 2, 2017
3 tasks
@Hainish
Hainish merged commit d3ced54 into EFForg:master Nov 2, 2017
@strugee
strugee deleted the fix-date-ignore-code branch November 2, 2017 23:19
@strugee strugee mentioned this pull request Apr 16, 2019
5 of 16 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants