-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 diff skipping lines #13154
Fix diff skipping lines #13154
Conversation
ParsePatch previously just skipped all lines that start with "+++ " or "--- " and makes no attempt to see these lines in context. This PR rewrites ParsePatch to pay attention to context and position within a patch, ensuring that --- and +++ are only skipped if appropriate. This PR also fixes several issues with incomplete files. Fix https://codeberg.org/Codeberg/Community/issues/308 Fix go-gitea#13153 Signed-off-by: Andrew Thornton <art27@cantab.net>
Backport go-gitea#13154 ParsePatch previously just skipped all lines that start with "+++ " or "--- " and makes no attempt to see these lines in context. This PR rewrites ParsePatch to pay attention to context and position within a patch, ensuring that --- and +++ are only skipped if appropriate. This PR also fixes several issues with incomplete files. Fix https://codeberg.org/Codeberg/Community/issues/308 Fix go-gitea#13153 Signed-off-by: Andrew Thornton <art27@cantab.net>
Backport go-gitea#13154 ParsePatch previously just skipped all lines that start with "+++ " or "--- " and makes no attempt to see these lines in context. This PR rewrites ParsePatch to pay attention to context and position within a patch, ensuring that --- and +++ are only skipped if appropriate. This PR also fixes several issues with incomplete files. Fix https://codeberg.org/Codeberg/Community/issues/308 Fix go-gitea#13153 Signed-off-by: Andrew Thornton <art27@cantab.net>
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.
First, thank you so much for this PR! I've been afraid of our diff parsing, and so I'm especially appreciative that you took this on. Second, would you hate me if I asked for tests, specifically ones for diffs with files that have lines that start with ++
and --
?
Oh sorry I've spent so much time making the current tests pass I forgot to add the real one |
Signed-off-by: Andrew Thornton <art27@cantab.net>
Done |
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Codecov Report
@@ Coverage Diff @@
## master #13154 +/- ##
==========================================
- Coverage 42.04% 42.03% -0.01%
==========================================
Files 681 681
Lines 75170 75220 +50
==========================================
+ Hits 31605 31619 +14
- Misses 38410 38438 +28
- Partials 5155 5163 +8
Continue to review full report at Codecov.
|
How about to use the package https://github.com/bluekeyes/go-gitdiff ? |
That's not a backportable change and would require lots of other changes. This isn't the last change I'm going to make to diff though and it's possible that that library could form part of it. |
…ments-in-pull-request-label-style * origin/master: [skip ci] Updated translations via Crowdin Fix diff skipping lines (go-gitea#13154) Update go-version v1.2.3 -> v1.2.4 (go-gitea#13169) Vendor Update Go Libs (go-gitea#13166) Prevent panics with missing storage (go-gitea#13164) Improve users management through the CLI (go-gitea#6001) (go-gitea#10492) Change order of possible-owner organizations to alphabetical (go-gitea#13160) Slightly simplify the queue settings code to help reduce the risk of problems (go-gitea#12976) [Vendor] Update go-ldap to v3.2.4 (go-gitea#13163) [skip ci] Updated translations via Crowdin Update external-renderers.en-us.md (go-gitea#13165)
* Fix diff skipping lines Backport #13154 ParsePatch previously just skipped all lines that start with "+++ " or "--- " and makes no attempt to see these lines in context. This PR rewrites ParsePatch to pay attention to context and position within a patch, ensuring that --- and +++ are only skipped if appropriate. This PR also fixes several issues with incomplete files. Fix https://codeberg.org/Codeberg/Community/issues/308 Fix #13153 Signed-off-by: Andrew Thornton <art27@cantab.net> * Add testcase Signed-off-by: Andrew Thornton <art27@cantab.net> * fix comment * simplify error handling Signed-off-by: Andrew Thornton <art27@cantab.net> * never return io.EOF Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix diff skipping lines Backport #13154 ParsePatch previously just skipped all lines that start with "+++ " or "--- " and makes no attempt to see these lines in context. This PR rewrites ParsePatch to pay attention to context and position within a patch, ensuring that --- and +++ are only skipped if appropriate. This PR also fixes several issues with incomplete files. Fix https://codeberg.org/Codeberg/Community/issues/308 Fix #13153 Signed-off-by: Andrew Thornton <art27@cantab.net> * Add testcase Signed-off-by: Andrew Thornton <art27@cantab.net> * fix comment * simplify error handling Signed-off-by: Andrew Thornton <art27@cantab.net> * never return io.EOF Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
ParsePatch previously just skipped all lines that start with "+++ " or "--- "
and makes no attempt to see these lines in context.
This PR rewrites ParsePatch to pay attention to context and position
within a patch, ensuring that --- and +++ are only skipped if
appropriate.
This PR also fixes several issues with incomplete files.
Fix https://codeberg.org/Codeberg/Community/issues/308
Fix #13153
Signed-off-by: Andrew Thornton art27@cantab.net