diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-19 21:39:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-19 21:39:57 +0800 |
commit | fc3d0826096943b979717ed46c9a4cfd86e06106 (patch) | |
tree | 3143882ccf4dea3a8bf2a0de9c8da9a4efec26ce /models/issue_xref.go | |
parent | 7a0347315995b25bcb2dca4786504fb699b5f004 (diff) | |
download | gitea-fc3d0826096943b979717ed46c9a4cfd86e06106.tar.gz gitea-fc3d0826096943b979717ed46c9a4cfd86e06106.zip |
Move attachment into models/repo/ (#17650)
* Move attachment into models/repo/
* Fix test
* Fix bug
Diffstat (limited to 'models/issue_xref.go')
-rw-r--r-- | models/issue_xref.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/models/issue_xref.go b/models/issue_xref.go index 4630f4d3a4..55483ce57b 100644 --- a/models/issue_xref.go +++ b/models/issue_xref.go @@ -5,6 +5,7 @@ package models import ( + "context" "fmt" "code.gitea.io/gitea/models/db" @@ -59,7 +60,7 @@ func neuterCrossReferencesIds(e db.Engine, ids []int64) error { // \/ \/ \/ // -func (issue *Issue) addCrossReferences(e db.Engine, doer *User, removeOld bool) error { +func (issue *Issue) addCrossReferences(stdCtx context.Context, doer *User, removeOld bool) error { var commentType CommentType if issue.IsPull { commentType = CommentTypePullRef @@ -72,10 +73,11 @@ func (issue *Issue) addCrossReferences(e db.Engine, doer *User, removeOld bool) OrigIssue: issue, RemoveOld: removeOld, } - return issue.createCrossReferences(e, ctx, issue.Title, issue.Content) + return issue.createCrossReferences(stdCtx, ctx, issue.Title, issue.Content) } -func (issue *Issue) createCrossReferences(e db.Engine, ctx *crossReferencesContext, plaincontent, mdcontent string) error { +func (issue *Issue) createCrossReferences(stdCtx context.Context, ctx *crossReferencesContext, plaincontent, mdcontent string) error { + e := db.GetEngine(stdCtx) xreflist, err := ctx.OrigIssue.getCrossReferences(e, ctx, plaincontent, mdcontent) if err != nil { return err @@ -125,7 +127,7 @@ func (issue *Issue) createCrossReferences(e db.Engine, ctx *crossReferencesConte RefAction: xref.Action, RefIsPull: ctx.OrigIssue.IsPull, } - _, err := createComment(e, opts) + _, err := createComment(stdCtx, opts) if err != nil { return err } @@ -240,11 +242,11 @@ func (issue *Issue) verifyReferencedIssue(e db.Engine, ctx *crossReferencesConte // \/ \/ \/ \/ \/ // -func (comment *Comment) addCrossReferences(e db.Engine, doer *User, removeOld bool) error { +func (comment *Comment) addCrossReferences(stdCtx context.Context, doer *User, removeOld bool) error { if comment.Type != CommentTypeCode && comment.Type != CommentTypeComment { return nil } - if err := comment.loadIssue(e); err != nil { + if err := comment.loadIssue(db.GetEngine(stdCtx)); err != nil { return err } ctx := &crossReferencesContext{ @@ -254,7 +256,7 @@ func (comment *Comment) addCrossReferences(e db.Engine, doer *User, removeOld bo OrigComment: comment, RemoveOld: removeOld, } - return comment.Issue.createCrossReferences(e, ctx, "", comment.Content) + return comment.Issue.createCrossReferences(stdCtx, ctx, "", comment.Content) } func (comment *Comment) neuterCrossReferences(e db.Engine) error { |