1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-23 08:47:42 -05:00
forgejo/docs/content/doc/advanced/migrations.en-us.md
zeripath 722a7c902d
Add Close() method to gogitRepository (#8901)
In investigating #7947 it has become clear that the storage component of go-git repositories needs closing.

This PR adds this Close function and adds the Close functions as necessary.

In TransferOwnership the ctx.Repo.GitRepo is closed if it is open to help prevent the risk of multiple open files.

Fixes #7947
2019-11-13 07:01:19 +00:00

2.3 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, only the migrations from github via APIv3 to Gitea is implemented.

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

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 {
	GetRepoInfo() (*Repository, error)
	GetTopics() ([]string, error)
	GetMilestones() ([]*Milestone, error)
	GetReleases() ([]*Release, error)
	GetLabels() ([]*Label, error)
	GetIssues(start, limit int) ([]*Issue, error)
	GetComments(issueNumber int64) ([]*Comment, error)
	GetPullRequests(start, limit int) ([]*PullRequest, error)
}
type DownloaderFactory interface {
	Match(opts MigrateOptions) (bool, error)
	New(opts MigrateOptions) (Downloader, error)
}

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 {
	CreateRepo(repo *Repository, includeWiki bool) error
	CreateMilestone(milestone *Milestone) error
	CreateRelease(release *Release) error
	CreateLabel(label *Label) error
	CreateIssue(issue *Issue) error
	CreateComment(issueNumber int64, comment *Comment) error
	CreatePullRequest(pr *PullRequest) error
	Rollback() error
	Close()
}