[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:
parent
131278ff22
commit
d453533beb
28 changed files with 234 additions and 208 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue