diff options
author | 6543 <6543@obermui.de> | 2022-05-08 15:46:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-08 15:46:34 +0200 |
commit | 6a969681cd862bf153fa7921485278be1e8a092a (patch) | |
tree | f9a23ee85652c0ee179f215b23d928058176ae6c /models/issue_comment.go | |
parent | 4344a6410788f30848e5153f6356dcdd0774bebc (diff) | |
download | gitea-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.go | 22 |
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 |