mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
[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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user