2022-07-30 18:45:59 +02:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
2022-11-27 19:20:29 +01:00
|
|
|
// SPDX-License-Identifier: MIT
|
2022-07-30 18:45:59 +02:00
|
|
|
|
|
|
|
package convert
|
|
|
|
|
|
|
|
import (
|
2023-10-03 12:30:41 +02:00
|
|
|
"context"
|
|
|
|
|
2022-07-30 18:45:59 +02:00
|
|
|
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 12:30:41 +02:00
|
|
|
func ToPushMirror(ctx context.Context, pm *repo_model.PushMirror) (*api.PushMirror, error) {
|
|
|
|
repo := pm.GetRepository(ctx)
|
2022-07-30 18:45:59 +02:00
|
|
|
return &api.PushMirror{
|
|
|
|
RepoName: repo.Name,
|
|
|
|
RemoteName: pm.RemoteName,
|
2023-09-16 18:03:02 +02:00
|
|
|
RemoteAddress: pm.RemoteAddress,
|
2023-09-23 14:15:05 +02:00
|
|
|
CreatedUnix: pm.CreatedUnix.AsTime(),
|
|
|
|
LastUpdateUnix: pm.LastUpdateUnix.AsTimePtr(),
|
2022-07-30 18:45:59 +02:00
|
|
|
LastError: pm.LastError,
|
|
|
|
Interval: pm.Interval.String(),
|
2023-02-23 22:50:33 +01:00
|
|
|
SyncOnCommit: pm.SyncOnCommit,
|
2024-08-04 20:46:05 +02:00
|
|
|
PublicKey: pm.GetPublicKey(),
|
2022-07-30 18:45:59 +02:00
|
|
|
}, nil
|
|
|
|
}
|