From 6151e69d9509c08e25e93743d6b31211371e81d0 Mon Sep 17 00:00:00 2001 From: caicandong <50507092+CaiCandong@users.noreply.github.com> Date: Fri, 4 Aug 2023 21:34:34 +0800 Subject: Delete `issue_service.CreateComment` (#26298) I noticed that `issue_service.CreateComment` adds transaction operations on `issues_model.CreateComment`, we can merge the two functions and we can avoid calling each other's methods in the `services` layer. Co-authored-by: Giteabot --- services/pull/comment.go | 3 +-- services/pull/pull.go | 4 ++-- services/pull/review.go | 7 +++---- 3 files changed, 6 insertions(+), 8 deletions(-) (limited to 'services/pull') diff --git a/services/pull/comment.go b/services/pull/comment.go index 24dfd8af0c..14fba52f1e 100644 --- a/services/pull/comment.go +++ b/services/pull/comment.go @@ -11,7 +11,6 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/json" - issue_service "code.gitea.io/gitea/services/issue" ) // getCommitIDsFromRepo get commit IDs from repo in between oldCommitID and newCommitID @@ -90,7 +89,7 @@ func CreatePushPullComment(ctx context.Context, pusher *user_model.User, pr *iss ops.Content = string(dataJSON) - comment, err = issue_service.CreateComment(ctx, ops) + comment, err = issues_model.CreateComment(ctx, ops) return comment, err } diff --git a/services/pull/pull.go b/services/pull/pull.go index cf49d2fe20..8730b9684d 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -125,7 +125,7 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, pull *issu Content: string(dataJSON), } - _, _ = issue_service.CreateComment(ctx, ops) + _, _ = issues_model.CreateComment(ctx, ops) if !pr.IsWorkInProgress() { if err := issues_model.PullRequestCodeOwnersReview(ctx, pull, pr); err != nil { @@ -231,7 +231,7 @@ func ChangeTargetBranch(ctx context.Context, pr *issues_model.PullRequest, doer OldRef: oldBranch, NewRef: targetBranch, } - if _, err = issue_service.CreateComment(ctx, options); err != nil { + if _, err = issues_model.CreateComment(ctx, options); err != nil { return fmt.Errorf("CreateChangeTargetBranchComment: %w", err) } diff --git a/services/pull/review.go b/services/pull/review.go index 59cc607912..58470142e1 100644 --- a/services/pull/review.go +++ b/services/pull/review.go @@ -20,7 +20,6 @@ import ( "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" - issue_service "code.gitea.io/gitea/services/issue" ) var notEnoughLines = regexp.MustCompile(`fatal: file .* has only \d+ lines?`) @@ -248,7 +247,7 @@ func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_mo return nil, err } } - return issue_service.CreateComment(ctx, &issues_model.CreateCommentOptions{ + return issues_model.CreateComment(ctx, &issues_model.CreateCommentOptions{ Type: issues_model.CommentTypeCode, Doer: doer, Repo: repo, @@ -340,7 +339,7 @@ func DismissApprovalReviews(ctx context.Context, doer *user_model.User, pull *is return err } - comment, err := issue_service.CreateComment(ctx, &issues_model.CreateCommentOptions{ + comment, err := issues_model.CreateComment(ctx, &issues_model.CreateCommentOptions{ Doer: doer, Content: "New commits pushed, approval review dismissed automatically according to repository settings", Type: issues_model.CommentTypeDismissReview, @@ -411,7 +410,7 @@ func DismissReview(ctx context.Context, reviewID, repoID int64, message string, return nil, err } - comment, err = issue_service.CreateComment(ctx, &issues_model.CreateCommentOptions{ + comment, err = issues_model.CreateComment(ctx, &issues_model.CreateCommentOptions{ Doer: doer, Content: message, Type: issues_model.CommentTypeDismissReview, -- cgit v1.2.3