gitea/docs/content/development/migrations.zh-cn.md

1.7 KiB
Raw Blame History

date title slug sidebar_position toc draft aliases menu
2023-05-25T17:29:00+08:00 迁移界面 migrations-interfaces 55 false false
/zh-cn/migrations-interfaces
sidebar
parent name sidebar_position identifier
development 迁移界面 55 migrations-interfaces

迁移功能

完整迁移功能在Gitea 1.9.0版本中引入。它定义了两个接口用于支持从其他Git托管平台迁移存储库数据到Gitea或者在将来将Gitea数据迁移到其他Git托管平台。

目前已实现了从GitHub、GitLab和其他Gitea实例的迁移。

首先Gitea在包modules/migration中定义了一些标准对象。它们是RepositoryMilestoneReleaseReleaseAssetLabelIssueCommentPullRequestReactionReviewReviewComment

下载器接口

要从新的Git托管平台迁移需要进行两个步骤的更新。

  • 您应该实现一个Downloader,用于获取存储库信息。
  • 您应该实现一个DownloaderFactory用于检测URL是否匹配并创建上述的Downloader
    • 您需要在init()中通过RegisterDownloaderFactory注册DownloaderFactory

您可以在downloader.go中找到这些接口。

上传器接口

目前,只实现了GiteaLocalUploader因此我们只能通过此Uploader将下载的数据保存到本地的Gitea实例。目前不支持其他上传器。

您可以在uploader.go中找到这些接口。