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/project_issue.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/project_issue.go')
-rw-r--r-- | models/project_issue.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/models/project_issue.go b/models/project_issue.go index 4e3bc0039d..75e74295b5 100644 --- a/models/project_issue.go +++ b/models/project_issue.go @@ -5,11 +5,10 @@ package models import ( + "context" "fmt" "code.gitea.io/gitea/models/db" - - "xorm.io/xorm" ) // ProjectIssue saves relation from issue to a project @@ -132,20 +131,21 @@ func (p *Project) NumOpenIssues() int { // ChangeProjectAssign changes the project associated with an issue func ChangeProjectAssign(issue *Issue, doer *User, newProjectID int64) error { - sess := db.NewSession(db.DefaultContext) - defer sess.Close() - if err := sess.Begin(); err != nil { + ctx, committer, err := db.TxContext() + if err != nil { return err } + defer committer.Close() - if err := addUpdateIssueProject(sess, issue, doer, newProjectID); err != nil { + if err := addUpdateIssueProject(ctx, issue, doer, newProjectID); err != nil { return err } - return sess.Commit() + return committer.Commit() } -func addUpdateIssueProject(e *xorm.Session, issue *Issue, doer *User, newProjectID int64) error { +func addUpdateIssueProject(ctx context.Context, issue *Issue, doer *User, newProjectID int64) error { + e := db.GetEngine(ctx) oldProjectID := issue.projectID(e) if _, err := e.Where("project_issue.issue_id=?", issue.ID).Delete(&ProjectIssue{}); err != nil { @@ -157,7 +157,7 @@ func addUpdateIssueProject(e *xorm.Session, issue *Issue, doer *User, newProject } if oldProjectID > 0 || newProjectID > 0 { - if _, err := createComment(e, &CreateCommentOptions{ + if _, err := createComment(ctx, &CreateCommentOptions{ Type: CommentTypeProject, Doer: doer, Repo: issue.Repo, |