diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-24 17:49:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 17:49:20 +0800 |
commit | a666829a37be6f9fd98f9e7dd1767c420f7f3b32 (patch) | |
tree | 9ab1434b759a8a2cb275a83149903a823851e309 /modules/repository/commits.go | |
parent | 4e7ca946da2a2642a62f114825129bf5d7ed9196 (diff) | |
download | gitea-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 'modules/repository/commits.go')
-rw-r--r-- | modules/repository/commits.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/modules/repository/commits.go b/modules/repository/commits.go index a545ce952b..8e727c95d0 100644 --- a/modules/repository/commits.go +++ b/modules/repository/commits.go @@ -9,8 +9,8 @@ import ( "net/url" "time" - "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/avatars" + user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" api "code.gitea.io/gitea/modules/structs" @@ -35,14 +35,14 @@ type PushCommits struct { Len int avatars map[string]string - emailUsers map[string]*models.User + emailUsers map[string]*user_model.User } // NewPushCommits creates a new PushCommits object. func NewPushCommits() *PushCommits { return &PushCommits{ avatars: make(map[string]string), - emailUsers: make(map[string]*models.User), + emailUsers: make(map[string]*user_model.User), } } @@ -52,7 +52,7 @@ func (pc *PushCommits) toAPIPayloadCommit(repoPath, repoLink string, commit *Pus authorUsername := "" author, ok := pc.emailUsers[commit.AuthorEmail] if !ok { - author, err = models.GetUserByEmail(commit.AuthorEmail) + author, err = user_model.GetUserByEmail(commit.AuthorEmail) if err == nil { authorUsername = author.Name pc.emailUsers[commit.AuthorEmail] = author @@ -64,7 +64,7 @@ func (pc *PushCommits) toAPIPayloadCommit(repoPath, repoLink string, commit *Pus committerUsername := "" committer, ok := pc.emailUsers[commit.CommitterEmail] if !ok { - committer, err = models.GetUserByEmail(commit.CommitterEmail) + committer, err = user_model.GetUserByEmail(commit.CommitterEmail) if err == nil { // TODO: check errors other than email not found. committerUsername = committer.Name @@ -107,7 +107,7 @@ func (pc *PushCommits) ToAPIPayloadCommits(repoPath, repoLink string) ([]*api.Pa var headCommit *api.PayloadCommit if pc.emailUsers == nil { - pc.emailUsers = make(map[string]*models.User) + pc.emailUsers = make(map[string]*user_model.User) } for i, commit := range pc.Commits { apiCommit, err := pc.toAPIPayloadCommit(repoPath, repoLink, commit) @@ -146,10 +146,10 @@ func (pc *PushCommits) AvatarLink(email string) string { u, ok := pc.emailUsers[email] if !ok { var err error - u, err = models.GetUserByEmail(email) + u, err = user_model.GetUserByEmail(email) if err != nil { pc.avatars[email] = avatars.GenerateEmailAvatarFastLink(email, size) - if !models.IsErrUserNotExist(err) { + if !user_model.IsErrUserNotExist(err) { log.Error("GetUserByEmail: %v", err) return "" } @@ -189,6 +189,6 @@ func GitToPushCommits(gitCommits []*git.Commit) *PushCommits { CompareURL: "", Len: len(commits), avatars: make(map[string]string), - emailUsers: make(map[string]*models.User), + emailUsers: make(map[string]*user_model.User), } } |