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

fix: GitLab Inline comments deleted with main comment updates #1382

Merged
merged 2 commits into from Jul 25, 2023

Conversation

DavidBrunow
Copy link
Contributor

@DavidBrunow DavidBrunow commented Apr 29, 2023

Fixes #1351 and possibly #1380.

I verified this fix with an inline comment and a main Danger note with DANGER_GITLAB_USE_THREADS both set and unset. With it unset all behavior looked good to me.

With that flag set, I am seeing an issue where the main Danger note was replacing the inline comment. Since that is not the intended behavior I tested the latest release with that flag set and also saw the same bad behavior there. Since that behavior is consistent I'd like to move forward with this pull request without trying to fix that behavior.

@DavidBrunow DavidBrunow force-pushed the bugfix/gitLabInlineComments branch 2 times, most recently from 0f72699 to 328ab2d Compare May 2, 2023 21:19
await this.deleteNotes(this.reduceNotesFromDiscussions(discussions)) //delete the rest

let newOrUpdatedNote: GitLabNote
if (useThreads()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main difference in the approach in this pull request is to treat the new "create a thread for the main comment" behavior as completely separate from the previous behavior to "create a note for the main comment".

Mixing the logic of these two behaviors caused issues where certain scenarios were not handled, like trying to update the "main" Danger comment and instead updating an inline comment because it was a discussion and the "main" Danger comment was not.

} else {
// create a new comment
newOrUpdatedNote = await this.createComment(newComment)
const notes: GitLabNote[] = await this.getMainDangerNotes(dangerID)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is copied from the code that existed before the change in #1331

const discussions = await this.getDangerDiscussions(dangerID)
return await this.deleteNotes(this.reduceNotesFromDiscussions(discussions))
} else {
const notes = await this.getMainDangerNotes(dangerID)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is copied from the code that existed before the change in #1331

@DavidBrunow DavidBrunow force-pushed the bugfix/gitLabInlineComments branch from 328ab2d to 5c5846a Compare May 2, 2023 22:09
@DavidBrunow DavidBrunow marked this pull request as ready for review May 3, 2023 22:37
@DavidBrunow
Copy link
Contributor Author

@squarefrog No problem if you don't have the bandwidth, but if you do I'd appreciate you giving this branch a test.

@squarefrog
Copy link
Contributor

I’m off work until next week but I can give it a try then, thanks for the tag!

@squarefrog
Copy link
Contributor

I'm really sorry for the delay in testing this. I've been on leave from work, then we've had issues with our CI setup. I'll need to see if I can figure out how to build the binary of this branch then try it.

@DavidBrunow
Copy link
Contributor Author

I'm really sorry for the delay in testing this. I've been on leave from work, then we've had issues with our CI setup. I'll need to see if I can figure out how to build the binary of this branch then try it.

Not a problem, life is busy and I keep getting distracted from this as well :)

@squarefrog
Copy link
Contributor

The good news is I figured out how to create a build of this and put it on our CI and it seems to work really well. Great job with this @DavidBrunow 🙌

@DavidBrunow
Copy link
Contributor Author

@orta Do you want to review or do you recommend any other reviewers before merging this?

@LucasWeber-git
Copy link

We are facing the same problem here. @orta it would be great if you could approve this merge.

@orta
Copy link
Member

orta commented Jul 25, 2023

Yeah, is @squarefrog is happy, I am happy

@orta orta merged commit 3d475ce into danger:main Jul 25, 2023
2 checks passed
@orta
Copy link
Member

orta commented Jul 25, 2023

Shipped

@DavidBrunow DavidBrunow deleted the bugfix/gitLabInlineComments branch August 29, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Inline comments often don't show up, or show incorrectly with GitLab self-hosted
5 participants