diff options
author | 6543 <6543@obermui.de> | 2020-10-17 06:23:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-17 00:23:08 -0400 |
commit | d453533beb197d25b25530dc5f0e3c3c0742d8d1 (patch) | |
tree | 6d66e1163333344d91af63e9ab50a82367470b8f /modules/convert/convert.go | |
parent | 131278ff222f1a8580f20e6bbdff405341403042 (diff) | |
download | gitea-d453533beb197d25b25530dc5f0e3c3c0742d8d1.tar.gz gitea-d453533beb197d25b25530dc5f0e3c3c0742d8d1.zip |
[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>
Diffstat (limited to 'modules/convert/convert.go')
-rw-r--r-- | modules/convert/convert.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/convert/convert.go b/modules/convert/convert.go index ec676002b9..e81df0c0c3 100644 --- a/modules/convert/convert.go +++ b/modules/convert/convert.go @@ -339,3 +339,24 @@ func ToOAuth2Application(app *models.OAuth2Application) *api.OAuth2Application { Created: app.CreatedUnix.AsTime(), } } + +// ToCommitStatus converts models.CommitStatus to api.Status +func ToCommitStatus(status *models.CommitStatus) *api.Status { + apiStatus := &api.Status{ + Created: status.CreatedUnix.AsTime(), + Updated: status.CreatedUnix.AsTime(), + State: api.StatusState(status.State), + TargetURL: status.TargetURL, + Description: status.Description, + ID: status.Index, + URL: status.APIURL(), + Context: status.Context, + } + + if status.CreatorID != 0 { + creator, _ := models.GetUserByID(status.CreatorID) + apiStatus.Creator = ToUser(creator, false, false) + } + + return apiStatus +} |