[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

@ -410,8 +410,17 @@ func (repo *Repository) innerAPIFormat(e Engine, mode AccessMode, isParent bool)
numReleases, _ := GetReleaseCountByRepoID(repo.ID, FindReleasesOptions{IncludeDrafts: false, IncludeTags: true})
return &api.Repository{
ID: repo.ID,
Owner: repo.Owner.APIFormat(),
ID: repo.ID,
// TODO use convert.ToUser(repo.Owner)
Owner: &api.User{
ID: repo.Owner.ID,
UserName: repo.Owner.Name,
FullName: repo.Owner.FullName,
Email: repo.Owner.GetEmail(),
AvatarURL: repo.Owner.AvatarLink(),
LastLogin: repo.Owner.LastLoginUnix.AsTime(),
Created: repo.Owner.CreatedUnix.AsTime(),
},
Name: repo.Name,
FullName: repo.FullName(),
Description: repo.Description,