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

Fix the bot commenting on edits more than once - #13294

Merged
Hainish merged 1 commit into
EFForg:masterfrom
strugee:issue-bot-edit-fix
Oct 25, 2017
Merged

Hainish merged 1 commit into
EFForg:masterfrom
strugee:issue-bot-edit-fix

Conversation

@strugee

@strugee strugee commented Oct 23, 2017

Copy link
Copy Markdown
Contributor

Note: this does the bare minimum to make tests pass. This change has no real test coverage, but this bug is causing real pain and I did test it manually in production so it'll have to do for now. At some point I'll send a followup PR adding the missing coverage.

Fixes #12855

Note: this does the *bare minimum* to make tests pass. This change has
no real test coverage, but this bug is causing real pain and I _did_
test it manually in production so it'll have to do for now.

Fixes EFForg#12855

@bardiharborow bardiharborow left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems reasonable as a quick patch, provided you have tested it appropriately. What would be preferable when you revisit this issue, is for the bot to edit it's original comment with any additional error messages, and for it to delete it's comment when all errors are resolved.

@cschanaj

Copy link
Copy Markdown
Collaborator

cc @Hainish @cowlicks


if (commentedBefore) return;

const params = context.issue({body: 'Thanks! Your edit helped me out. I\'ll take it from here now. <!-- HELPED_COMMENT_POSTED -->'});

@ghost ghost Oct 24, 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 params = context.issue({ body: "Thanks! Your edit helped me out. I'll take it from here now. <!-- HELPED_COMMENT_POSTED -->" });

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.

@koops76 what's the difference, besides the quotes? I've consistently been using single quotes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's ok to use double quotes to avoid escaping

};
},
addLabels: sinon.spy(),
removeLabel: sinon.spy(() => new Promise(noop))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

removeLabel: sinon.spy(() => Promise.resolve())?

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.

I think new Promise(noop) makes it clearer what's going on - we're creating a new Promise that's a noop. Whereas with your example you have to know offhand what Promise.resolve() does.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

new Promise(noop) never resolves since resolve is never called.

}));
const allComments = _allComments.data;

allComments.forEach(comment => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

for (const comment of allComments) {

//
// XXX handle the user screwing up, then fixing it (and getting
// the success comment), then screwing up again
const _allComments = await context.github.issues.getComments(context.issue({

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 allComments = (await context.github.issues.getComments(context.issue({
  per_page: 100, // eslint-disable-line camelcase
  since: '2017-09-25'
}))).data;

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.

I did this originally but decided the other way made what was happening clearer. Your version is super dense :)

@ghost ghost Oct 25, 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.

At least call it allCommentsData instead of the same name but without an underscore.

@Hainish

Hainish commented Oct 25, 2017

Copy link
Copy Markdown
Member

Thanks, this looks good to me. Merging and deploying fix now.

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.

4 participants