summaryrefslogtreecommitdiffstats
path: root/models/task.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-12-10 09:27:50 +0800
committerGitHub <noreply@github.com>2021-12-10 09:27:50 +0800
commit719bddcd76610a63dadc8555760072957a11cf30 (patch)
tree0df26092fba7e3e21444fe493e6b349473b6b0cb /models/task.go
parentfb8166c6c6b652a0e6fa98681780a6a71090faf3 (diff)
downloadgitea-719bddcd76610a63dadc8555760072957a11cf30.tar.gz
gitea-719bddcd76610a63dadc8555760072957a11cf30.zip
Move repository model into models/repo (#17933)
* Some refactors related repository model * Move more methods out of repository * Move repository into models/repo * Fix test * Fix test * some improvements * Remove unnecessary function
Diffstat (limited to 'models/task.go')
-rw-r--r--models/task.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/models/task.go b/models/task.go
index 1999957270..64c858921c 100644
--- a/models/task.go
+++ b/models/task.go
@@ -8,6 +8,7 @@ import (
"fmt"
"code.gitea.io/gitea/models/db"
+ repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/migration"
@@ -23,12 +24,12 @@ import (
// Task represents a task
type Task struct {
ID int64
- DoerID int64 `xorm:"index"` // operator
- Doer *user_model.User `xorm:"-"`
- OwnerID int64 `xorm:"index"` // repo owner id, when creating, the repoID maybe zero
- Owner *user_model.User `xorm:"-"`
- RepoID int64 `xorm:"index"`
- Repo *Repository `xorm:"-"`
+ DoerID int64 `xorm:"index"` // operator
+ Doer *user_model.User `xorm:"-"`
+ OwnerID int64 `xorm:"index"` // repo owner id, when creating, the repoID maybe zero
+ Owner *user_model.User `xorm:"-"`
+ RepoID int64 `xorm:"index"`
+ Repo *repo_model.Repository `xorm:"-"`
Type structs.TaskType
Status structs.TaskStatus `xorm:"index"`
StartTime timeutil.TimeStamp
@@ -57,12 +58,12 @@ func (task *Task) loadRepo(e db.Engine) error {
if task.Repo != nil {
return nil
}
- var repo Repository
+ var repo repo_model.Repository
has, err := e.ID(task.RepoID).Get(&repo)
if err != nil {
return err
} else if !has {
- return ErrRepoNotExist{
+ return repo_model.ErrRepoNotExist{
ID: task.RepoID,
}
}