From 319a978c6c717c754717ceccf8c784f07ba9b582 Mon Sep 17 00:00:00 2001 From: arkamar Date: Mon, 2 May 2022 03:09:34 +0800 Subject: [PATCH] Allow PR review with comments only (#570) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is common to create PR review with Comments only, where foreword Body is empty. This is allowed by Gitea API, therefore SDK should return empty body error only if there are no comments. Co-authored-by: Petr Vaněk Co-authored-by: Lunny Xiao Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/570 Reviewed-by: Norwin Reviewed-by: Andrew Thornton Co-authored-by: arkamar Co-committed-by: arkamar --- gitea/pull_review.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitea/pull_review.go b/gitea/pull_review.go index a484dfd..6d32c4f 100644 --- a/gitea/pull_review.go +++ b/gitea/pull_review.go @@ -116,7 +116,7 @@ type ListPullReviewsOptions struct { // Validate the CreatePullReviewOptions struct func (opt CreatePullReviewOptions) Validate() error { - if opt.State != ReviewStateApproved && len(strings.TrimSpace(opt.Body)) == 0 { + if opt.State != ReviewStateApproved && len(opt.Comments) == 0 && len(strings.TrimSpace(opt.Body)) == 0 { return fmt.Errorf("body is empty") } for i := range opt.Comments {