code.gitea.io/gitea@v1.21.7/services/convert/mirror.go (about)

     1  // Copyright 2022 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package convert
     5  
     6  import (
     7  	repo_model "code.gitea.io/gitea/models/repo"
     8  	api "code.gitea.io/gitea/modules/structs"
     9  )
    10  
    11  // ToPushMirror convert from repo_model.PushMirror and remoteAddress to api.TopicResponse
    12  func ToPushMirror(pm *repo_model.PushMirror) (*api.PushMirror, error) {
    13  	repo := pm.GetRepository()
    14  	return &api.PushMirror{
    15  		RepoName:       repo.Name,
    16  		RemoteName:     pm.RemoteName,
    17  		RemoteAddress:  pm.RemoteAddress,
    18  		CreatedUnix:    pm.CreatedUnix.FormatLong(),
    19  		LastUpdateUnix: pm.LastUpdateUnix.FormatLong(),
    20  		LastError:      pm.LastError,
    21  		Interval:       pm.Interval.String(),
    22  		SyncOnCommit:   pm.SyncOnCommit,
    23  	}, nil
    24  }