[Refactor] Move APIFormat functions into convert package (#12856)

* USER APIFormat -> ToUser

* Migrate more and mark APIFormat deprecated

* models.Comment APIFormat() -> convert.ToComment

* models.Release APIFormat() -> convert.ToRelease

* models.Attachments APIFormat() -> convert.ToReleaseAttachments

* models.CommitStatus APIFormat() -> convert.ToCommitStatus

* finish migration to convert.ToUser

* Move Test

* Imprufe Test

* fix test

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
6543 2020-10-17 06:23:08 +02:00 committed by GitHub
parent 131278ff22
commit d453533beb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 234 additions and 208 deletions

View file

@ -86,13 +86,13 @@ func ToCommit(repo *models.Repository, commit *git.Commit, userCache map[string]
}
if ok {
apiAuthor = cacheAuthor.APIFormat()
apiAuthor = ToUser(cacheAuthor, false, false)
} else {
author, err := models.GetUserByEmail(commit.Author.Email)
if err != nil && !models.IsErrUserNotExist(err) {
return nil, err
} else if err == nil {
apiAuthor = author.APIFormat()
apiAuthor = ToUser(author, false, false)
if userCache != nil {
userCache[commit.Author.Email] = author
}
@ -108,13 +108,13 @@ func ToCommit(repo *models.Repository, commit *git.Commit, userCache map[string]
}
if ok {
apiCommitter = cacheCommitter.APIFormat()
apiCommitter = ToUser(cacheCommitter, false, false)
} else {
committer, err := models.GetUserByEmail(commit.Committer.Email)
if err != nil && !models.IsErrUserNotExist(err) {
return nil, err
} else if err == nil {
apiCommitter = committer.APIFormat()
apiCommitter = ToUser(committer, false, false)
if userCache != nil {
userCache[commit.Committer.Email] = committer
}