diff options
author | Giteabot <teabot@gitea.io> | 2023-12-05 16:58:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-05 16:58:15 +0800 |
commit | 8b590de186dffdbe240cb5c58f5ec17f16fdbe25 (patch) | |
tree | f301677c1a38939ad13205ee8ec5c28b85d1bfba /services/migrations | |
parent | 5105d2093c55925654ccfa6e2d3130de09f2272d (diff) | |
download | gitea-8b590de186dffdbe240cb5c58f5ec17f16fdbe25.tar.gz gitea-8b590de186dffdbe240cb5c58f5ec17f16fdbe25.zip |
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 <70063547+lng2020@users.noreply.github.com>
Diffstat (limited to 'services/migrations')
-rw-r--r-- | services/migrations/gitea_uploader.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go index 9e4adc55be..838562abd4 100644 --- a/services/migrations/gitea_uploader.go +++ b/services/migrations/gitea_uploader.go @@ -862,7 +862,7 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error { line := comment.Line if line != 0 { comment.Position = 1 - } else { + } else if comment.DiffHunk != "" { _, _, line, _ = git.ParseDiffHunkString(comment.DiffHunk) } |