Skip to content

Commit 8b590de

Browse files
GiteaBotlng2020
andauthored
Fix migration panic due to an empty review comment diff (#28334) (#28362)
Backport #28334 by @lng2020 Fix #28328 ``` func (p *PullRequestComment) GetDiffHunk() string { if p == nil || p.DiffHunk == nil { return "" } return *p.DiffHunk } ``` This function in the package `go-github` may return an empty diff. When it's empty, the following code will panic because it access `ss[1]` https://github.com/go-gitea/gitea/blob/ec1feedbf582b05b6a5e8c59fb2457f25d053ba2/services/migrations/gitea_uploader.go#L861-L867 https://github.com/go-gitea/gitea/blob/ec1feedbf582b05b6a5e8c59fb2457f25d053ba2/modules/git/diff.go#L97-L101 Co-authored-by: Nanguan Lin <[email protected]>
1 parent 5105d20 commit 8b590de

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

services/migrations/gitea_uploader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
862862
line := comment.Line
863863
if line != 0 {
864864
comment.Position = 1
865-
} else {
865+
} else if comment.DiffHunk != "" {
866866
_, _, line, _ = git.ParseDiffHunkString(comment.DiffHunk)
867867
}
868868

0 commit comments

Comments
 (0)