summaryrefslogtreecommitdiffstats
path: root/models/issue_comment.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-05-08 15:46:34 +0200
committerGitHub <noreply@github.com>2022-05-08 15:46:34 +0200
commit6a969681cd862bf153fa7921485278be1e8a092a (patch)
treef9a23ee85652c0ee179f215b23d928058176ae6c /models/issue_comment.go
parent4344a6410788f30848e5153f6356dcdd0774bebc (diff)
downloadgitea-6a969681cd862bf153fa7921485278be1e8a092a.tar.gz
gitea-6a969681cd862bf153fa7921485278be1e8a092a.zip
Delete related PullAutoMerge and ReviewState on User/Repo Deletion (#19649)
* delete pullautomerges on repo/user deletion * delete reviewstates on repo/user deletion * optimize automerhe code * add index to reviewstate
Diffstat (limited to 'models/issue_comment.go')
-rw-r--r--models/issue_comment.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/models/issue_comment.go b/models/issue_comment.go
index 13b2c62546..2cf3d5a61d 100644
--- a/models/issue_comment.go
+++ b/models/issue_comment.go
@@ -1360,6 +1360,28 @@ func CreatePushPullComment(ctx context.Context, pusher *user_model.User, pr *Pul
return
}
+// CreateAutoMergeComment is a internal function, only use it for CommentTypePRScheduledToAutoMerge and CommentTypePRUnScheduledToAutoMerge CommentTypes
+func CreateAutoMergeComment(ctx context.Context, typ CommentType, pr *PullRequest, doer *user_model.User) (comment *Comment, err error) {
+ if typ != CommentTypePRScheduledToAutoMerge && typ != CommentTypePRUnScheduledToAutoMerge {
+ return nil, fmt.Errorf("comment type %d cannot be used to create an auto merge comment", typ)
+ }
+ if err = pr.LoadIssueCtx(ctx); err != nil {
+ return
+ }
+
+ if err = pr.LoadBaseRepoCtx(ctx); err != nil {
+ return
+ }
+
+ comment, err = CreateCommentCtx(ctx, &CreateCommentOptions{
+ Type: typ,
+ Doer: doer,
+ Repo: pr.BaseRepo,
+ Issue: pr.Issue,
+ })
+ return
+}
+
// getCommitsFromRepo get commit IDs from repo in between oldCommitID and newCommitID
// isForcePush will be true if oldCommit isn't on the branch
// Commit on baseBranch will skip