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

feat: Reverse PR Comments Order #4005

Closed
wants to merge 10 commits into from

Conversation

wpbeckwith
Copy link
Contributor

@wpbeckwith wpbeckwith commented Dec 1, 2023

what

This PR reverses the order of PR comments so that when they are posted to a PR, they will read from top to bottom as a logical block.

why

Assume there is a big terraform long that will be posted and it will be donme as 2 separate comments. The current behavior will post comments block 3, then 2 and finally 1. his causes users to need to scroll to the 1st comment block, read down, then scroll back up past the beginng of the 1st block and to find the beginiing of block 2 and read down, then repeat that process for block 3.

tests

There is a simple function that just reverses the slice array and there's a test for that function. We have also been running this in production for 1.5 years with 100's of PR builds a day.

references

@wpbeckwith wpbeckwith requested a review from a team as a code owner December 1, 2023 18:27
@github-actions github-actions bot added go Pull requests that update Go code provider/bitbucket labels Dec 1, 2023
@wpbeckwith
Copy link
Contributor Author

wpbeckwith commented Dec 1, 2023

I think I have all the config settings in place. I just need to know how to read the config setting in the various clients to make the logic conditional.

@wpbeckwith wpbeckwith changed the title Comment changes feat: Reverse PR Comments Order Dec 1, 2023
@kvanzuijlen
Copy link
Contributor

This is not something I've seen personally on GitHub. Which VCS do you use? Maybe this issue is specific to that one? In that case, I'd approach this as a bug and make the correct way the new default. Not sure what the maintainers think?

@wpbeckwith
Copy link
Contributor Author

This is not something I've seen personally on GitHub. Which VCS do you use? Maybe this issue is specific to that one? In that case, I'd approach this as a bug and make the correct way the new default. Not sure what the maintainers think?

Have you had PR comments larger than 65k?

@kvanzuijlen
Copy link
Contributor

Have you had PR comments larger than 65k?

I've had plans spanning multiple comments, so I guess so.

@@ -137,6 +137,8 @@ func (b *Client) CreateComment(repo models.Repo, pullNum int, comment string, co
sepEnd := "\n```\n**Warning**: Output length greater than max comment size. Continued in next comment."
sepStart := "Continued from previous comment.\n```diff\n"
comments := common.SplitComment(comment, maxCommentLength, sepEnd, sepStart)
common.ReverseComments(comments)
Copy link
Contributor

Choose a reason for hiding this comment

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

As of 1.21 (which atlantis uses), go has a standard library module slices for generic slice operations, including Reverse(). I'd recommend this be used and the test removed.

Suggested change
common.ReverseComments(comments)
slices.Reverse(comments)

@lukemassa
Copy link
Contributor

@brandon-fryslie, you mentioned in #3905 frequently having output split across multiple comments; do you have an opinion about whether the current ordering should be default, the reverse, or if it should be configurable?

@jamengual jamengual added the waiting-on-response Waiting for a response from the user label May 24, 2024
Copy link

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.

@github-actions github-actions bot added the Stale label Jun 25, 2024
@github-actions github-actions bot closed this Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support posting PR comments in reverse order for VCS
4 participants