2022-07-30 22:15:59 +05:30
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2022-07-30 22:15:59 +05:30
|
|
|
|
|
|
|
package convert
|
|
|
|
|
|
|
|
import (
|
2023-10-03 16:00:41 +05:30
|
|
|
"context"
|
|
|
|
|
2022-07-30 22:15:59 +05:30
|
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
|
|
|
api "code.gitea.io/gitea/modules/structs"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ToPushMirror convert from repo_model.PushMirror and remoteAddress to api.TopicResponse
|
2023-10-03 16:00:41 +05:30
|
|
|
func ToPushMirror(ctx context.Context, pm *repo_model.PushMirror) (*api.PushMirror, error) {
|
|
|
|
repo := pm.GetRepository(ctx)
|
2022-07-30 22:15:59 +05:30
|
|
|
return &api.PushMirror{
|
|
|
|
RepoName: repo.Name,
|
|
|
|
RemoteName: pm.RemoteName,
|
2023-09-16 21:33:02 +05:30
|
|
|
RemoteAddress: pm.RemoteAddress,
|
2023-09-23 17:45:05 +05:30
|
|
|
CreatedUnix: pm.CreatedUnix.AsTime(),
|
|
|
|
LastUpdateUnix: pm.LastUpdateUnix.AsTimePtr(),
|
2022-07-30 22:15:59 +05:30
|
|
|
LastError: pm.LastError,
|
|
|
|
Interval: pm.Interval.String(),
|
2023-02-24 03:20:33 +05:30
|
|
|
SyncOnCommit: pm.SyncOnCommit,
|
2022-07-30 22:15:59 +05:30
|
|
|
}, nil
|
|
|
|
}
|