fix(ParsedMerge): only parse conflicts starting at newlines; render conflicts with non-newline-terminated sides correctly #185

Merged
ada4a merged 17 commits from ada4a/mergiraf:parsed_merge_parse_at_newline into main 2025-02-04 11:14:46 +01:00
Owner

fixes #149, refer to it for motivation
depends on #184

I can't believe I'm finally done with this.

The commits are somewhat less neatly separated than usually, but should be possible to follow nevertheless

fixes #149, refer to it for motivation depends on #184 I can't believe I'm finally done with this. The commits are somewhat less neatly separated than usually, but should be possible to follow nevertheless
this aligns nicely with the structure of `DisplaySettings` since #161

one could use `NonEmptyString` for some additional type-safety, but I
think that'd be superfluous
style: replace match with if-let
All checks were successful
/ test (pull_request) Successful in 42s
984889a0a2
wetneb approved these changes 2025-02-03 16:07:48 +01:00
wetneb left a comment
Owner

Impressive work! I think the extensive test cases show for themselves.
I had mixed feelings about ignoring malformed conflicts as this could cover up some issues, but it does feel like the right thing to do after all, especially since it could trigger in cases where a conflict-like string is intentionally included in the contents.

Impressive work! I think the extensive test cases show for themselves. I had mixed feelings about ignoring malformed conflicts as this could cover up some issues, but it does feel like the right thing to do after all, especially since it could trigger in cases where a conflict-like string is intentionally included in the contents.
Author
Owner

Impressive work!

Thank you:)

I think the extensive test cases show for themselves.

There are actually two main reasons for this.

  1. getting a regex (and a rather complex one in this case) right is pretty hard -- I've spent an entire day just fixing one only to break three more, then fixing those, more errors, etc...
  2. because of the difficulties with regex, I really wanted to use nom instead, but couldn't bring the "there can be an arbitrarily big chunk of text between the two conflict markers, so proceed until you find one, and their sizes can vary by the way" thing to work, and ended up giving up. Because of that, I decided to encode as much of the behavior I expect from the regex as I could -- both in order to make sure future refactorings don't break it, and to have something to compare against when someone (hopefully) finds a way to migrate away from the regex.

but it does feel like the right thing to do after all, especially since it could trigger in cases where a conflict-like string is intentionally included in the contents.

Yeah, that's what I ended up deciding as well.

> Impressive work! Thank you:) > I think the extensive test cases show for themselves. There are actually two main reasons for this. 1) getting a regex (and a rather complex one in this case) right is pretty hard -- I've spent an entire day just fixing one only to break three more, then fixing those, more errors, etc... 2) because of the difficulties with regex, I really wanted to use [`nom`](https://crates.io/crates/nom) instead, but couldn't bring the "there can be an arbitrarily big chunk of text between the two conflict markers, so proceed until you find one, and their sizes can vary by the way" thing to work, and ended up giving up. Because of that, I decided to encode as much of the behavior I expect from the regex as I could -- both in order to make sure future refactorings don't break it, and to have something to compare against when someone (hopefully) finds a way to migrate away from the regex. > but it does feel like the right thing to do after all, especially since it could trigger in cases where a conflict-like string is intentionally included in the contents. Yeah, that's what I ended up deciding as well.
ada4a force-pushed parsed_merge_parse_at_newline from 6244ba2355 to dcb5b90e3d 2025-02-04 10:57:05 +01:00 Compare
ada4a force-pushed parsed_merge_parse_at_newline from dcb5b90e3d to a67b321eeb 2025-02-04 10:58:25 +01:00 Compare
ada4a force-pushed parsed_merge_parse_at_newline from 933abb30e5 to 1f7d2c1840 2025-02-04 11:11:42 +01:00 Compare
ada4a merged commit b8e0675f44 into main 2025-02-04 11:14:46 +01:00
ada4a deleted branch parsed_merge_parse_at_newline 2025-02-04 11:14:47 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: mergiraf/mergiraf#185
No description provided.