Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Never post the same comment twice #79

Closed
darkwing opened this issue Jun 30, 2015 · 11 comments
Closed

Never post the same comment twice #79

darkwing opened this issue Jun 30, 2015 · 11 comments

Comments

@darkwing
Copy link
Contributor

If a pull request is submitted, then another commit pushed to that branch (thus updating the PR), the entire PR is then reevaluated and commit comments duplicated.
00000300

@openjck openjck changed the title Duplicate comments added Don't re-commend on old lines when another commit is added to a pull request Jun 30, 2015
@openjck openjck changed the title Don't re-commend on old lines when another commit is added to a pull request Don't re-comment on old lines when another commit is added to a pull request Jun 30, 2015
@openjck openjck added the bug label Jun 30, 2015
@darkwing
Copy link
Contributor Author

darkwing commented Jul 1, 2015

I was thinking about this, and thinking we could read all comments from our bot and delete them via the API, but if they have replies, that would mess things up.

@Faeranne
Copy link
Contributor

Faeranne commented Jul 3, 2015

I do believe that we can access just the most recent commit, but since PR comments occur on the merge commit that may confuse things. Any reason we shouldn't re-comment on issues in the PR?

@darkwing
Copy link
Contributor Author

darkwing commented Jul 3, 2015

My issue is that let's say a PR goes back and forth a dozen times...do we want a dozen comments for the same change for each update/commit? It's too much noise, IMO. We should at least dig for a better solution.

@Faeranne
Copy link
Contributor

Faeranne commented Jul 3, 2015

We could just ignore files that haven't changed in the last commit. Those that have will loose the original; comments, so we will need to re-comment if they haven't been fixed.

@openjck
Copy link
Contributor

openjck commented Jul 6, 2015

Lines that change will lose their comments, but only those lines. So re-commenting on files that have changed won't be enough.

@Faeranne
Copy link
Contributor

Faeranne commented Jul 7, 2015

The latest commit should only have lines that have changed. Perhaps we use only the latest commit to determine which lines have changes, and build comments from that? Since we would still have merge commit numbers, it should only be one additional call to github to fetch the latest commit diff.

@openjck
Copy link
Contributor

openjck commented Jul 7, 2015

We'll also need to handle the case where someone rewrites the history of a branch.

I wonder if we might be over-thinking it. Would something as simple as not adding a comment if one already exists work?

@Faeranne
Copy link
Contributor

Faeranne commented Jul 7, 2015

What if someone else made a comment on the line? I agree that it seems like there should be a simpler answer, but i'd bet that we could release a fix with what we have now.

As for branch rewrites? I believe Github will clear all comments when that happens, so we use the latest commit, which should have all the changes again. This is one of the reasons I feel that rewriting history should be saved for the actual PR merge, or not executed at all, but it's definitely a problem we need to solve.

@Faeranne
Copy link
Contributor

Faeranne commented Jul 7, 2015

If #89 gets completed, we can use the db to track comments easily.

@openjck openjck modified the milestone: MVQ Jul 8, 2015
@openjck openjck changed the title Don't re-comment on old lines when another commit is added to a pull request Don't re-comment on old lines when updates are made to a pull request Jul 8, 2015
@openjck openjck removed this from the MVP #1 milestone Aug 22, 2015
@openjck openjck changed the title Don't re-comment on old lines when updates are made to a pull request Never post the same comment twice Dec 31, 2015
@openjck
Copy link
Contributor

openjck commented Dec 31, 2015

This can be triggered by a few things, including but not limited to rebasing a commit, adding a new commit to the same branch, and closing/reopening a pull request.

@openjck
Copy link
Contributor

openjck commented Dec 31, 2015

Quoting @groovecoder from #151:

@openjck and I thought a solution may be:

  1. Create a comments table in our shiny new postgres database
  2. Update the comment code to store a hash of the url, file name, line number, and line contents
  3. Before making a comment, make sure there isn't already a comment record with the same hash

That file name, line number, and line contents combination seems to be the same keys that GitHub uses to decide whether to collapse comments in the PR interface. But we can tweak the hash components as needed.

@openjck openjck self-assigned this Jan 20, 2016
openjck added a commit to openjck/discord that referenced this issue Jan 27, 2016
openjck added a commit to openjck/discord that referenced this issue Jan 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants