Skip to content

Commit

Permalink
Fix migration panic due to an empty review comment diff (go-gitea#28334)
Browse files Browse the repository at this point in the history
Fix go-gitea#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
  • Loading branch information
lng2020 authored Dec 5, 2023
1 parent a95d5b7 commit 49b98e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion services/migrations/gitea_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 49b98e4

Please sign in to comment.