]> source.dussan.org Git - gitea.git/commit
Fix a couple of CommentAsPatch issues. (#14804) (#14820)
authorzeripath <art27@cantab.net>
Sun, 28 Feb 2021 13:19:51 +0000 (13:19 +0000)
committerGitHub <noreply@github.com>
Sun, 28 Feb 2021 13:19:51 +0000 (15:19 +0200)
commitbe25afc6def888f9ec83b3e8ebe1c1fed216b19a
treedb1addef6601427c133f8ab46887fb2445457a20
parent90bf1e7961cf428c378e93726dcb7f2cb6da24c1
Fix a couple of CommentAsPatch issues.  (#14804) (#14820)

Backport #14804

* CutDiffAroundLine makes the incorrect assumption that `---` and `+++` always represent part of the header of a diff.

This PR adds a flag to its parsing to prevent this problem and adds a streaming parsing technique to CutDiffAroundLine using an io.pipe instead of just sending data to an unbounded buffer.

Fix #14711

* Handle unquoted comment patch files

When making comment patches unfortunately the patch does not always quote the filename
This makes the diff --git header ambiguous again.

This PR finally adds handling for ambiguity in to parse patch

Fix #14812

* Add in testing for no error

There is no way currently for CutDiffAroundLine in this test to cause an
error however, it should still be tested.

Signed-off-by: Andrew Thornton <art27@cantab.net>
modules/git/diff.go
modules/git/diff_test.go
modules/migrations/gitea_uploader.go
services/gitdiff/gitdiff.go
services/gitdiff/gitdiff_test.go
services/pull/review.go