1
0
mirror of https://github.com/go-gitea/gitea synced 2024-11-14 01:35:54 +01:00
gitea/docs/content/doc/advanced/migrations.en-us.md
6543 49b1948cb1
Gitea 2 Gitea migration (#12657)
* first draft

* update gitea sdk to 9e280adb4da

* adapt feat of updated sdk

* releases now works

* break the Reactions loop

* use convertGiteaLabel

* fix endless loop because paggination is not supported there !!!

* rename gitea local uploader files

* pagination can bite you in the ass

* Version Checks

* lint

* docs

* rename gitea sdk import to miss future conficts

* go-swagger: dont scan the sdk structs

* make sure gitea can shutdown gracefully

* make GetPullRequests and GetIssues similar

* rm useles

* Add Test: started ...

* ... add tests ...

* Add tests and Fixing things

* Workaround missing SHA

* Adapt: Ensure that all migration requests are cancellable
(714ab71ddc4260937b1480519d453d2dc4e77dd6)

* LINT: fix misspells in test set

* adapt ListMergeRequestAwardEmoji

* update sdk

* Return error when creating giteadownloader failed

* update sdk

* adapt new sdk

* adopt new features

* check version before err

* adapt: 'migrate service type switch page'

* optimize

* Fix DefaultBranch

* impruve

* handle subPath

* fix test

* Fix ReviewCommentPosition

* test GetReviews

* add DefaultBranch int test set

* rm unused

* Update SDK to v0.13.0

* addopt sdk changes

* found better link

* format template

* Update Docs

* Update Gitea SDK (v0.13.1)
2020-10-14 07:06:00 +03:00

2.7 KiB

date title slug weight toc draft menu
2019-04-15T17:29:00+08:00 Advanced: Migrations Interfaces migrations-interfaces 30 true false
sidebar
parent name weight identifier
advanced Migrations Interfaces 55 migrations-interfaces

Migration Features

The new migration features were introduced in Gitea 1.9.0. It defines two interfaces to support migrating repositories data from other git host platforms to gitea or, in the future migrating gitea data to other git host platforms. Currently, migrations from Github, Gitlab and Gitea to Gitea is implemented.

First of all, Gitea defines some standard objects in packages modules/migrations/base. They are Repository, Milestone, Release, ReleaseAsset, Label, Issue, Comment, PullRequest, Reaction, Review, ReviewComment.

Downloader Interfaces

To migrate from a new git host platform, there are two steps to be updated.

  • You should implement a Downloader which will get all kinds of repository informations.
  • You should implement a DownloaderFactory which is used to detect if the URL matches and create a Downloader.
  • You'll need to register the DownloaderFactory via RegisterDownloaderFactory on init.
type Downloader interface {
	GetAsset(relTag string, relID, id int64) (io.ReadCloser, error)
	SetContext(context.Context)
	GetRepoInfo() (*Repository, error)
	GetTopics() ([]string, error)
	GetMilestones() ([]*Milestone, error)
	GetReleases() ([]*Release, error)
	GetLabels() ([]*Label, error)
	GetIssues(page, perPage int) ([]*Issue, bool, error)
	GetComments(issueNumber int64) ([]*Comment, error)
	GetPullRequests(page, perPage int) ([]*PullRequest, bool, error)
	GetReviews(pullRequestNumber int64) ([]*Review, error)
}
type DownloaderFactory interface {
	New(ctx context.Context, opts MigrateOptions) (Downloader, error)
	GitServiceType() structs.GitServiceType
}

Uploader Interface

Currently, only a GiteaLocalUploader is implemented, so we only save downloaded data via this Uploader on the local Gitea instance. Other uploaders are not supported and will be implemented in future.

// Uploader uploads all the informations
type Uploader interface {
	MaxBatchInsertSize(tp string) int
	CreateRepo(repo *Repository, opts MigrateOptions) error
	CreateTopics(topic ...string) error
	CreateMilestones(milestones ...*Milestone) error
	CreateReleases(downloader Downloader, releases ...*Release) error
	SyncTags() error
	CreateLabels(labels ...*Label) error
	CreateIssues(issues ...*Issue) error
	CreateComments(comments ...*Comment) error
	CreatePullRequests(prs ...*PullRequest) error
	CreateReviews(reviews ...*Review) error
	Rollback() error
	Close()
}