Fix diff skipping lines #13154

Merged
lunny merged 10 commits from fix-13153-parsepatch-rewrite into master 2020-10-16 17:13:19 +00:00
Contributor

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

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>
techknowlogick reviewed 2020-10-15 05:52:02 +00:00
techknowlogick left a comment
Contributor

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 --?

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 `--`?
zeripath reviewed 2020-10-15 06:06:08 +00:00
Author
Contributor
	// - we might want to consider detecting encoding while parsing but...
```suggestion // - we might want to consider detecting encoding while parsing but... ```
techknowlogick reviewed 2020-10-15 06:22:02 +00:00

I've attempted to trace through this loop to search for an err that is previously unhandled such that this conditional would be needed. Although it is an unreasonable hour for me to be awake, let alone doing PR reviews, so I am likely missing something, and should return in the morning with fresh eyes.

I've attempted to trace through this loop to search for an err that is previously unhandled such that this conditional would be needed. Although it is an unreasonable hour for me to be awake, let alone doing PR reviews, so I am likely missing something, and should return in the morning with fresh eyes.
zeripath reviewed 2020-10-15 06:39:39 +00:00
Author
Contributor

Sorry that's a hang over from earlier code and error handing. I've removed it now and should have improved handling in general.

Sorry that's a hang over from earlier code and error handing. I've removed it now and should have improved handling in general.
techknowlogick approved these changes 2020-10-16 00:14:00 +00:00
lafriks (Migrated from github.com) approved these changes 2020-10-16 09:10:09 +00:00
This repo is archived. You cannot comment on pull requests.
No Milestone
No project
No Assignees
3 Participants
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: lunny/gitea#13154
No description provided.