You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

migrations.en-us.md 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ---
  2. date: "2019-04-15T17:29:00+08:00"
  3. title: "Advanced: Migrations Interfaces"
  4. slug: "migrations-interfaces"
  5. weight: 30
  6. toc: true
  7. draft: false
  8. menu:
  9. sidebar:
  10. parent: "advanced"
  11. name: "Migrations Interfaces"
  12. weight: 55
  13. identifier: "migrations-interfaces"
  14. ---
  15. # Migration Features
  16. The new migration features were introduced in Gitea 1.9.0. It defines two interfaces to support migrating
  17. repositories data from other git host platforms to gitea or, in the future migrating gitea data to other
  18. git host platforms. Currently, only the migrations from github via APIv3 to Gitea is implemented.
  19. First of all, Gitea defines some standard objects in packages `modules/migrations/base`. They are
  20. `Repository`, `Milestone`, `Release`, `Label`, `Issue`, `Comment`, `PullRequest`.
  21. ## Downloader Interfaces
  22. To migrate from a new git host platform, there are two steps to be updated.
  23. - You should implement a `Downloader` which will get all kinds of repository informations.
  24. - You should implement a `DownloaderFactory` which is used to detect if the URL matches and
  25. create a Downloader.
  26. - You'll need to register the `DownloaderFactory` via `RegisterDownloaderFactory` on init.
  27. ```Go
  28. type Downloader interface {
  29. GetRepoInfo() (*Repository, error)
  30. GetMilestones() ([]*Milestone, error)
  31. GetReleases() ([]*Release, error)
  32. GetLabels() ([]*Label, error)
  33. GetIssues(start, limit int) ([]*Issue, error)
  34. GetComments(issueNumber int64) ([]*Comment, error)
  35. GetPullRequests(start, limit int) ([]*PullRequest, error)
  36. }
  37. ```
  38. ```Go
  39. type DownloaderFactory interface {
  40. Match(opts MigrateOptions) (bool, error)
  41. New(opts MigrateOptions) (Downloader, error)
  42. }
  43. ```
  44. ## Uploader Interface
  45. Currently, only a `GiteaLocalUploader` is implemented, so we only save downloaded
  46. data via this `Uploader` on the local Gitea instance. Other uploaders are not supported
  47. and will be implemented in future.
  48. ```Go
  49. // Uploader uploads all the informations
  50. type Uploader interface {
  51. CreateRepo(repo *Repository, includeWiki bool) error
  52. CreateMilestone(milestone *Milestone) error
  53. CreateRelease(release *Release) error
  54. CreateLabel(label *Label) error
  55. CreateIssue(issue *Issue) error
  56. CreateComment(issueNumber int64, comment *Comment) error
  57. CreatePullRequest(pr *PullRequest) error
  58. Rollback() error
  59. }
  60. ```