mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +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:
		@@ -61,27 +61,6 @@ func (status *CommitStatus) APIURL() string {
 | 
			
		||||
		setting.AppURL, status.Repo.FullName(), status.SHA)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// APIFormat assumes some fields assigned with values:
 | 
			
		||||
// Required - Repo, Creator
 | 
			
		||||
func (status *CommitStatus) APIFormat() *api.Status {
 | 
			
		||||
	_ = status.loadRepo(x)
 | 
			
		||||
	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.Creator != nil {
 | 
			
		||||
		apiStatus.Creator = status.Creator.APIFormat()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return apiStatus
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CalcCommitStatus returns commit status state via some status, the commit statues should order by id desc
 | 
			
		||||
func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus {
 | 
			
		||||
	var lastStatus *CommitStatus
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user