summaryrefslogtreecommitdiffstats
path: root/models/task.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-24 17:49:20 +0800
committerGitHub <noreply@github.com>2021-11-24 17:49:20 +0800
commita666829a37be6f9fd98f9e7dd1767c420f7f3b32 (patch)
tree9ab1434b759a8a2cb275a83149903a823851e309 /models/task.go
parent4e7ca946da2a2642a62f114825129bf5d7ed9196 (diff)
downloadgitea-a666829a37be6f9fd98f9e7dd1767c420f7f3b32.tar.gz
gitea-a666829a37be6f9fd98f9e7dd1767c420f7f3b32.zip
Move user related model into models/user (#17781)
* Move user related model into models/user * Fix lint for windows * Fix windows lint * Fix windows lint * Move some tests in models * Merge
Diffstat (limited to 'models/task.go')
-rw-r--r--models/task.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/models/task.go b/models/task.go
index 9bff00cd8c..1999957270 100644
--- a/models/task.go
+++ b/models/task.go
@@ -8,6 +8,7 @@ import (
"fmt"
"code.gitea.io/gitea/models/db"
+ user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/migration"
"code.gitea.io/gitea/modules/secret"
@@ -22,12 +23,12 @@ import (
// Task represents a task
type Task struct {
ID int64
- DoerID int64 `xorm:"index"` // operator
- Doer *User `xorm:"-"`
- OwnerID int64 `xorm:"index"` // repo owner id, when creating, the repoID maybe zero
- Owner *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 *Repository `xorm:"-"`
Type structs.TaskType
Status structs.TaskStatus `xorm:"index"`
StartTime timeutil.TimeStamp
@@ -75,12 +76,12 @@ func (task *Task) LoadDoer() error {
return nil
}
- var doer User
+ var doer user_model.User
has, err := db.GetEngine(db.DefaultContext).ID(task.DoerID).Get(&doer)
if err != nil {
return err
} else if !has {
- return ErrUserNotExist{
+ return user_model.ErrUserNotExist{
UID: task.DoerID,
}
}
@@ -95,12 +96,12 @@ func (task *Task) LoadOwner() error {
return nil
}
- var owner User
+ var owner user_model.User
has, err := db.GetEngine(db.DefaultContext).ID(task.OwnerID).Get(&owner)
if err != nil {
return err
} else if !has {
- return ErrUserNotExist{
+ return user_model.ErrUserNotExist{
UID: task.OwnerID,
}
}