Fix error when syncing comments when PR is not synced

This commit is contained in:
harryzcy 2023-04-06 12:09:22 -04:00
parent 1c8b8ef8a0
commit 9af62926bf
No known key found for this signature in database
GPG Key ID: E3C2287691E40E35
1 changed files with 4 additions and 1 deletions

View File

@ -476,7 +476,10 @@ func (g *GiteaLocalUploader) prepareComments(comments ...*base.Comment) ([]*issu
var issue *issues_model.Issue
issue, ok := g.issues[comment.IssueIndex]
if !ok {
return nil, fmt.Errorf("comment references non existent IssueIndex %d", comment.IssueIndex)
// ignore comments for non existent issues
// It can happen when a comment belongs to a pull request, but the pull request is not imported
log.Warn("Ignoring comment for non existent issue %d", comment.IssueIndex)
continue
}
if comment.Created.IsZero() {