-
-
Notifications
You must be signed in to change notification settings - Fork 22
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: improve body parsing logic #72
base: main
Are you sure you want to change the base?
Conversation
Discovered by this openwrt/openwrt#15265 Made further research and found the root of the problem! |
20e3584
to
7b837e5
Compare
7b837e5
to
14c673f
Compare
Current body parsing logic with trim() + split("###") is too fragile and pose problems with some body that contains case with ### in the middle of the line or case with codeblock ``` section. These case will cause the script to parse these as separate section and produce wrong outputs and in some case even prints error assuming things are checkbox and errors out on the concat function. To make the parsing logic more solid, implement a dedicated function and parse with this logic: - We split the body for "\n" - We ignore codeblock ``` section - We check "###" only at the start of the line - We check for "### " (with the space included) as that is the correct section Github issue template expects. With the following change case like: ``` root@OpenWrt:~# cat /boot/config.txt ``` Are correctly parsed as all part of a single section instead of being wrongly treated as different empty sections. Signed-off-by: Christian Marangi <[email protected]>
Add additional test for section with #### to prevent and catch in future code change that would produce wrong parsing. Signed-off-by: Christian Marangi <[email protected]>
Add test for codeblock ``` ignore to prevent and catch in future code change that would produce wrong parsing. Signed-off-by: Christian Marangi <[email protected]>
Add test for codeblock ```sh ignore to prevent and catch in future code change that would produce wrong parsing. This is a variant of the ``` test that makes the code block section target specific code. Signed-off-by: Christian Marangi <[email protected]>
14c673f
to
06dd03d
Compare
@jamacku sorry for the delay... I fixed the comment and also add an additional test to catch this special case. We check now if line start with ``` directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thank you.
Awesome, good stuff. I will have a closer look shortly and then cut a new major version for this change. |
Current body parsing logic with trim() + split("###") is too fragile and
pose problems with some body that contains case with ### in the middle
of the line or case with codeblock ``` section.
These case will cause the script to parse these as separate section and
produce wrong outputs and in some case even prints error assuming things
are checkbox and errors out on the concat function.
To make the parsing logic more solid, implement a dedicated function and
parse with this logic:
section Github issue template expects.
With the following change case like:
Are correctly parsed as all part of a single section instead of being
wrongly treated as different empty sections.
Signed-off-by: Christian Marangi [email protected]