From d3846df1f996d6ae4f95ea51ad6f927234fddac3 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 13 Feb 2024 23:29:33 +0100 Subject: [PATCH 1/6] Dont load Review if Comment is CommentTypeReviewRequest (#28551) (#29160) Backport #28551 RequestReview get deleted on review. So we don't have to try to load them on comments. (cherry picked from commit 0ac3186267b717bce7076ef44f883df7720d7a2d) --- models/issues/comment.go | 7 +++++++ models/issues/comment_list.go | 3 ++- models/issues/review.go | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/models/issues/comment.go b/models/issues/comment.go index 8dc8c7682d..40da4d88b1 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -688,8 +688,15 @@ func (c *Comment) LoadReactions(ctx context.Context, repo *repo_model.Repository } func (c *Comment) loadReview(ctx context.Context) (err error) { + if c.ReviewID == 0 { + return nil + } if c.Review == nil { if c.Review, err = GetReviewByID(ctx, c.ReviewID); err != nil { + // review request which has been replaced by actual reviews doesn't exist in database anymore, so ignorem them. + if c.Type == CommentTypeReviewRequest { + return nil + } return err } } diff --git a/models/issues/comment_list.go b/models/issues/comment_list.go index 93af45870e..cb7df3270d 100644 --- a/models/issues/comment_list.go +++ b/models/issues/comment_list.go @@ -430,7 +430,8 @@ func (comments CommentList) loadReviews(ctx context.Context) error { for _, comment := range comments { comment.Review = reviews[comment.ReviewID] if comment.Review == nil { - if comment.ReviewID > 0 { + // review request which has been replaced by actual reviews doesn't exist in database anymore, so don't log errors for them. + if comment.ReviewID > 0 && comment.Type != CommentTypeReviewRequest { log.Error("comment with review id [%d] but has no review record", comment.ReviewID) } continue diff --git a/models/issues/review.go b/models/issues/review.go index eae8c20e97..5bfb8b9dd2 100644 --- a/models/issues/review.go +++ b/models/issues/review.go @@ -622,6 +622,9 @@ func AddReviewRequest(ctx context.Context, issue *Issue, reviewer, doer *user_mo return nil, err } + // func caller use the created comment to retrieve created review too. + comment.Review = review + return comment, committer.Commit() } From aced7547c2fa88a2a626f2b0169741905e8b6dc8 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Wed, 14 Feb 2024 18:51:51 +0100 Subject: [PATCH 2/6] Use ghost user if user was not found (#29161) (#29169) Backport #29161 (cherry picked from commit d823465d94b3b43945eace060000db9334eca52d) --- models/issues/comment_list.go | 4 ++++ models/issues/review.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/models/issues/comment_list.go b/models/issues/comment_list.go index cb7df3270d..30a437ea50 100644 --- a/models/issues/comment_list.go +++ b/models/issues/comment_list.go @@ -225,6 +225,10 @@ func (comments CommentList) loadAssignees(ctx context.Context) error { for _, comment := range comments { comment.Assignee = assignees[comment.AssigneeID] + if comment.Assignee == nil { + comment.AssigneeID = user_model.GhostUserID + comment.Assignee = user_model.NewGhostUser() + } } return nil } diff --git a/models/issues/review.go b/models/issues/review.go index 5bfb8b9dd2..3fca30d7b6 100644 --- a/models/issues/review.go +++ b/models/issues/review.go @@ -159,6 +159,14 @@ func (r *Review) LoadReviewer(ctx context.Context) (err error) { return err } r.Reviewer, err = user_model.GetPossibleUserByID(ctx, r.ReviewerID) + if err != nil { + if !user_model.IsErrUserNotExist(err) { + return fmt.Errorf("GetPossibleUserByID [%d]: %w", r.ReviewerID, err) + } + r.ReviewerID = user_model.GhostUserID + r.Reviewer = user_model.NewGhostUser() + return nil + } return err } From 8782275c9c66ad6fc7c44503d7df9dae7196aa65 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 17 Feb 2024 20:06:55 +0800 Subject: [PATCH 3/6] Fix push to create with capitalize repo name (#29090) (#29206) Fix #29073 Backport #29090 Co-authored-by: KN4CK3R (cherry picked from commit 933cc4da642c13b18423be99574944c43cc558c7) --- cmd/serv.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/serv.go b/cmd/serv.go index 43e6eaba2b..15cbbe910e 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -216,16 +216,18 @@ func runServ(c *cli.Context) error { } } - // LowerCase and trim the repoPath as that's how they are stored. - repoPath = strings.ToLower(strings.TrimSpace(repoPath)) - rr := strings.SplitN(repoPath, "/", 2) if len(rr) != 2 { return fail(ctx, "Invalid repository path", "Invalid repository path: %v", repoPath) } - username := strings.ToLower(rr[0]) - reponame := strings.ToLower(strings.TrimSuffix(rr[1], ".git")) + username := rr[0] + reponame := strings.TrimSuffix(rr[1], ".git") + + // LowerCase and trim the repoPath as that's how they are stored. + // This should be done after splitting the repoPath into username and reponame + // so that username and reponame are not affected. + repoPath = strings.ToLower(strings.TrimSpace(repoPath)) if alphaDashDotPattern.MatchString(reponame) { return fail(ctx, "Invalid repo name", "Invalid repo name: %s", reponame) From a40762d929c20e4b480084c23eed9529f86ee2e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Nicas=20Oelschl=C3=A4ger?= <72873130+zokkis@users.noreply.github.com> Date: Sun, 18 Feb 2024 19:51:00 +0100 Subject: [PATCH 4/6] Convert visibility to number (#29226) (#29244) Backport #29226 Don't throw error while creating user (Fixes #29218) --- The backport info from Giteabot https://github.com/go-gitea/gitea/pull/29226#issuecomment-1951341322 needs to specify the version, because the default is v1.18 (cherry picked from commit 39735c43a8b6f7db3b3e3531ca9115a60335d524) --- templates/admin/user/new.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/admin/user/new.tmpl b/templates/admin/user/new.tmpl index 81f70511d0..bcb53d8131 100644 --- a/templates/admin/user/new.tmpl +++ b/templates/admin/user/new.tmpl @@ -26,7 +26,7 @@