Skip to content

Commit 49b98e4

Browse files
authored
Fix migration panic due to an empty review comment diff (#28334)
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
1 parent a95d5b7 commit 49b98e4

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)