-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[WIP][RFC] Fix broken format for continued comments on GitHub #203
Conversation
hm linter fails, but I dunno why :( pls advice |
Hey thank for the PR! looks like the linter is a bit broken. Don't worry about it. I'll take a look. |
So there's a couple of changes I think we need to make:
Here are the test cases I was using: https://gist.github.com/lkysow/f161a756fa9cca532493589a0677c338 What do you think? |
Oh also, if you rebase off of master the linter warnings should be fixed. |
hey @lkysow - thanks for you great feedback. Fully agree on all. I should have read the markdown code syntax a bite more carefully :) I hope to get it done by end of the week.. let's see :) |
@lkysow quick update, I'm still on this. That's what I got so far. works, but I feel it's still over-engineered. I ran in the problem to solve it for every special case, but in practise those usecase are rare/unlikely. I'd like to give it another try with more assumptions:
What you think? btw. by using recursion I found it easier to solve & keep code readable. But as I'm quite with unexperienced with golang, I'm unsure how a high size stack depth is handled. Any recommendation here? Maybe with my assumptions above I can go back to iterative approach with maintaining readability |
Yes I think it would be best to write the algorithm with some assumptions and just throw an error if they're not met. It will make the code much easier to understand and test. That being said, the assumptions that can be made are:
It's incorrect to assume that multiple open and closes won't happen because in a repo with multiple terraform projects, when Atlantis autoplans it includes the plans for each project in a single comment, ex: Atlantis ran plan in 2 projects:
dir:
|
@rngtng you still working on this? Definitely something I need as well. |
We now wrap comments in an expandable block:
So that's what will need to be closed and re-opened now. |
sorry my silence here, I wish & plan to continue the fix, but I recently received my second child, so focus is currently bit shifted 😄 I'll consider the new format, IMHO this will make things even simpler.. 👍 |
@rngtng do you need any assistance with this? |
@sstarcher honestly: yes, I'd very much appreciate it. I currently just don't find the time to get it done. After multiple rounds using line split, recursion, regexp etc. I'm now thinking we may keep the current approach but add close and (re)open Please feel free to take this over if you have a solution in mind. |
Adds close and (re)open <details> tag in between the split portions to ensure the markup is correct across multiple comments. This isn't the prettiest, but a close result, under the assumption continued-comments are in 99% within a terraform output anyway...
Just pushed a commit inserting a close and (re)open |
@sstarcher @lkysow any feedback on this? |
I think a simple close/reopen of the details would be the easiest thing. I have not had a chance to test out your changes. |
@rngtng ack I totally missed your message about adding the |
@rngtng it's merged! I think I will remember this PR as what happens when we try to overengineer something. The algorithm you wrote was pretty cool but I like the simplicity of what you ended up with better. Thanks for sticking with it. |
👍 indeed - you don't know how much this kept bugging me - completeness/correctness vs. simplicity/pragmatism .. I'll take this challenge to my next job candidate interview ;D |
* Resolved merge conflict * stats scope * swap default and gateway
This addssplitAtLineBreak
which splits comment into a slice with string up to max len separated by join which gets appended to the ends of the middle strings.If a split contains a single needle, we append it, as well to next middle string to get the count balanced. This ensures the formatting is correct.It’s for sure not the nicest solution, but parsing markdown or similar felt overhead.I on purpose didn’t changedsplitAtMaxChars
in first place for introducing the algo & easier code review, but I guess this can be easily merged intosplitAtLineBreak
when we accept that a comment with no linebreak is no realise scenario we have to consider properly.Adds close and (re)open
<details>
tag in between the split portions toensure the markup is correct across multiple comments. This isn't the prettiest, but a close result, under the assumption continued-comments are in 99% within a terraform output anyway...
ref: #111