summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-05-07 09:12:51 +0800
committerGitHub <noreply@github.com>2019-05-07 09:12:51 +0800
commit08069dc4656fa53ee5dd25189e15012cb4f8acb2 (patch)
tree2e08cb239fef3221e55da75f106dfcb0140e08a1 /docs
parent1c7c739eb9ea1d2ffdaed3c776c84d42858c0851 (diff)
downloadgitea-08069dc4656fa53ee5dd25189e15012cb4f8acb2.tar.gz
gitea-08069dc4656fa53ee5dd25189e15012cb4f8acb2.zip
Improve migrations to support migrating milestones/labels/issues/comments/pullrequests (#6290)
* add migrations * fix package dependency * fix lints * implements migrations except pull requests * add releases * migrating releases * fix bug * fix lint * fix migrate releases * fix tests * add rollback * pull request migtations * fix import * fix go module vendor * add tests for upload to gitea * more migrate options * fix swagger-check * fix misspell * add options on migration UI * fix log error * improve UI options on migrating * add support for username password when migrating from github * fix tests * remove comments and fix migrate limitation * improve error handles * migrate API will also support migrate milestones/labels/issues/pulls/releases * fix tests and remove unused codes * add DownloaderFactory and docs about how to create a new Downloader * fix misspell * fix migration docs * Add hints about migrate options on migration page * fix tests
Diffstat (limited to 'docs')
-rw-r--r--docs/content/doc/advanced/migrations.en-us.md72
1 files changed, 72 insertions, 0 deletions
diff --git a/docs/content/doc/advanced/migrations.en-us.md b/docs/content/doc/advanced/migrations.en-us.md
new file mode 100644
index 0000000000..7db9cad817
--- /dev/null
+++ b/docs/content/doc/advanced/migrations.en-us.md
@@ -0,0 +1,72 @@
+---
+date: "2019-04-15T17:29:00+08:00"
+title: "Advanced: Migrations Interfaces"
+slug: "migrations-interfaces"
+weight: 30
+toc: true
+draft: false
+menu:
+ sidebar:
+ parent: "advanced"
+ name: "Migrations Interfaces"
+ weight: 55
+ identifier: "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.
+
+```Go
+type Downloader interface {
+ GetRepoInfo() (*Repository, 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)
+}
+```
+
+```Go
+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.
+
+```Go
+// 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
+}
+
+``` \ No newline at end of file