-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
type/refactoringExisting code has been cleaned up. There should be no new functionality.Existing code has been cleaned up. There should be no new functionality.
Description
Feature Description
I think the GetOwner
here should be LoadOwner
. Get
means return something and Load
means something is nil
, we need to load it.
This func dosen't return anything, but the description of this func says GetOwner returns the repository owner
Lines 376 to 384 in 8bba7e3
// GetOwner returns the repository owner | |
func (repo *Repository) GetOwner(ctx context.Context) (err error) { | |
if repo.Owner != nil { | |
return nil | |
} | |
repo.Owner, err = user_model.GetUserByID(ctx, repo.OwnerID) | |
return err | |
} |
In other places, the functions which do samething are called LoadOwner
gitea/models/project/project.go
Lines 110 to 116 in 8bba7e3
func (p *Project) LoadOwner(ctx context.Context) (err error) { | |
if p.Owner != nil { | |
return nil | |
} | |
p.Owner, err = user_model.GetUserByID(ctx, p.OwnerID) | |
return err | |
} |
Lines 95 to 112 in 8bba7e3
func (task *Task) LoadOwner() error { | |
if task.Owner != nil { | |
return nil | |
} | |
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 user_model.ErrUserNotExist{ | |
UID: task.OwnerID, | |
} | |
} | |
task.Owner = &owner | |
return nil | |
} |
Screenshots
No response
lunny
Metadata
Metadata
Assignees
Labels
type/refactoringExisting code has been cleaned up. There should be no new functionality.Existing code has been cleaned up. There should be no new functionality.