gitea: code.gitea.io/gitea/modules/migrations Index | Files | Directories

package migrations

import "code.gitea.io/gitea/modules/migrations"

Index

Package Files

dump.go error.go git.go gitea_downloader.go gitea_uploader.go github.go gitlab.go gogs.go migrate.go restore.go update.go

Variables

var (
    // ErrRepoNotCreated returns the error that repository not created
    ErrRepoNotCreated = errors.New("repository is not created yet")
)
var (

    // GithubLimitRateRemaining limit to wait for new rate to apply
    GithubLimitRateRemaining = 0
)

func DumpRepository Uses

func DumpRepository(ctx context.Context, baseDir, ownerName string, opts base.MigrateOptions) error

DumpRepository dump repository according MigrateOptions to a local directory

func Init Uses

func Init() error

Init migrations service

func IsRateLimitError Uses

func IsRateLimitError(err error) bool

IsRateLimitError returns true if the err is github.RateLimitError

func IsTwoFactorAuthError Uses

func IsTwoFactorAuthError(err error) bool

IsTwoFactorAuthError returns true if the err is github.TwoFactorAuthError

func MigrateRepository Uses

func MigrateRepository(ctx context.Context, doer *models.User, ownerName string, opts base.MigrateOptions) (*models.Repository, error)

MigrateRepository migrate repository according MigrateOptions

func RegisterDownloaderFactory Uses

func RegisterDownloaderFactory(factory base.DownloaderFactory)

RegisterDownloaderFactory registers a downloader factory

func RestoreRepository Uses

func RestoreRepository(ctx context.Context, baseDir string, ownerName, repoName string) error

RestoreRepository restore a repository from the disk directory

func UpdateMigrationPosterID Uses

func UpdateMigrationPosterID(ctx context.Context) error

UpdateMigrationPosterID updates all migrated repositories' issues and comments posterID

type GiteaDownloader Uses

type GiteaDownloader struct {
    base.NullDownloader
    // contains filtered or unexported fields
}

GiteaDownloader implements a Downloader interface to get repository information's

func NewGiteaDownloader Uses

func NewGiteaDownloader(ctx context.Context, baseURL, repoPath, username, password, token string) (*GiteaDownloader, error)

NewGiteaDownloader creates a gitea Downloader via gitea API

Use either a username/password or personal token. token is preferred
Note: Public access only allows very basic access

func (*GiteaDownloader) GetComments Uses

func (g *GiteaDownloader) GetComments(index int64) ([]*base.Comment, error)

GetComments returns comments according issueNumber

func (*GiteaDownloader) GetIssues Uses

func (g *GiteaDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, error)

GetIssues returns issues according start and limit

func (*GiteaDownloader) GetLabels Uses

func (g *GiteaDownloader) GetLabels() ([]*base.Label, error)

GetLabels returns labels

func (*GiteaDownloader) GetMilestones Uses

func (g *GiteaDownloader) GetMilestones() ([]*base.Milestone, error)

GetMilestones returns milestones

func (*GiteaDownloader) GetPullRequests Uses

func (g *GiteaDownloader) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)

GetPullRequests returns pull requests according page and perPage

func (*GiteaDownloader) GetReleases Uses

func (g *GiteaDownloader) GetReleases() ([]*base.Release, error)

GetReleases returns releases

func (*GiteaDownloader) GetRepoInfo Uses

func (g *GiteaDownloader) GetRepoInfo() (*base.Repository, error)

GetRepoInfo returns a repository information

func (*GiteaDownloader) GetReviews Uses

func (g *GiteaDownloader) GetReviews(index int64) ([]*base.Review, error)

GetReviews returns pull requests review

func (*GiteaDownloader) GetTopics Uses

func (g *GiteaDownloader) GetTopics() ([]string, error)

GetTopics return gitea topics

func (*GiteaDownloader) SetContext Uses

func (g *GiteaDownloader) SetContext(ctx context.Context)

SetContext set context

type GiteaDownloaderFactory Uses

type GiteaDownloaderFactory struct {
}

GiteaDownloaderFactory defines a gitea downloader factory

func (*GiteaDownloaderFactory) GitServiceType Uses

func (f *GiteaDownloaderFactory) GitServiceType() structs.GitServiceType

GitServiceType returns the type of git service

func (*GiteaDownloaderFactory) New Uses

func (f *GiteaDownloaderFactory) New(ctx context.Context, opts base.MigrateOptions) (base.Downloader, error)

New returns a Downloader related to this factory according MigrateOptions

type GiteaLocalUploader Uses

type GiteaLocalUploader struct {
    // contains filtered or unexported fields
}

GiteaLocalUploader implements an Uploader to gitea sites

func NewGiteaLocalUploader Uses

func NewGiteaLocalUploader(ctx context.Context, doer *models.User, repoOwner, repoName string) *GiteaLocalUploader

NewGiteaLocalUploader creates an gitea Uploader via gitea API v1

func (*GiteaLocalUploader) Close Uses

func (g *GiteaLocalUploader) Close()

Close closes this uploader

func (*GiteaLocalUploader) CreateComments Uses

func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error

CreateComments creates comments of issues

func (*GiteaLocalUploader) CreateIssues Uses

func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error

CreateIssues creates issues

func (*GiteaLocalUploader) CreateLabels Uses

func (g *GiteaLocalUploader) CreateLabels(labels ...*base.Label) error

CreateLabels creates labels

func (*GiteaLocalUploader) CreateMilestones Uses

func (g *GiteaLocalUploader) CreateMilestones(milestones ...*base.Milestone) error

CreateMilestones creates milestones

func (*GiteaLocalUploader) CreatePullRequests Uses

func (g *GiteaLocalUploader) CreatePullRequests(prs ...*base.PullRequest) error

CreatePullRequests creates pull requests

func (*GiteaLocalUploader) CreateReleases Uses

func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error

CreateReleases creates releases

func (*GiteaLocalUploader) CreateRepo Uses

func (g *GiteaLocalUploader) CreateRepo(repo *base.Repository, opts base.MigrateOptions) error

CreateRepo creates a repository

func (*GiteaLocalUploader) CreateReviews Uses

func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error

CreateReviews create pull request reviews

func (*GiteaLocalUploader) CreateTopics Uses

func (g *GiteaLocalUploader) CreateTopics(topics ...string) error

CreateTopics creates topics

func (*GiteaLocalUploader) Finish Uses

func (g *GiteaLocalUploader) Finish() error

Finish when migrating success, this will do some status update things.

func (*GiteaLocalUploader) MaxBatchInsertSize Uses

func (g *GiteaLocalUploader) MaxBatchInsertSize(tp string) int

MaxBatchInsertSize returns the table's max batch insert size

func (*GiteaLocalUploader) Rollback Uses

func (g *GiteaLocalUploader) Rollback() error

Rollback when migrating failed, this will rollback all the changes.

func (*GiteaLocalUploader) SyncTags Uses

func (g *GiteaLocalUploader) SyncTags() error

SyncTags syncs releases with tags in the database

type GithubDownloaderV3 Uses

type GithubDownloaderV3 struct {
    base.NullDownloader
    // contains filtered or unexported fields
}

GithubDownloaderV3 implements a Downloader interface to get repository informations from github via APIv3

func NewGithubDownloaderV3 Uses

func NewGithubDownloaderV3(ctx context.Context, baseURL, userName, password, token, repoOwner, repoName string) *GithubDownloaderV3

NewGithubDownloaderV3 creates a github Downloader via github v3 API

func (*GithubDownloaderV3) GetComments Uses

func (g *GithubDownloaderV3) GetComments(issueNumber int64) ([]*base.Comment, error)

GetComments returns comments according issueNumber

func (*GithubDownloaderV3) GetIssues Uses

func (g *GithubDownloaderV3) GetIssues(page, perPage int) ([]*base.Issue, bool, error)

GetIssues returns issues according start and limit

func (*GithubDownloaderV3) GetLabels Uses

func (g *GithubDownloaderV3) GetLabels() ([]*base.Label, error)

GetLabels returns labels

func (*GithubDownloaderV3) GetMilestones Uses

func (g *GithubDownloaderV3) GetMilestones() ([]*base.Milestone, error)

GetMilestones returns milestones

func (*GithubDownloaderV3) GetPullRequests Uses

func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)

GetPullRequests returns pull requests according page and perPage

func (*GithubDownloaderV3) GetReleases Uses

func (g *GithubDownloaderV3) GetReleases() ([]*base.Release, error)

GetReleases returns releases

func (*GithubDownloaderV3) GetRepoInfo Uses

func (g *GithubDownloaderV3) GetRepoInfo() (*base.Repository, error)

GetRepoInfo returns a repository information

func (*GithubDownloaderV3) GetReviews Uses

func (g *GithubDownloaderV3) GetReviews(pullRequestNumber int64) ([]*base.Review, error)

GetReviews returns pull requests review

func (*GithubDownloaderV3) GetTopics Uses

func (g *GithubDownloaderV3) GetTopics() ([]string, error)

GetTopics return github topics

func (*GithubDownloaderV3) RefreshRate Uses

func (g *GithubDownloaderV3) RefreshRate() error

RefreshRate update the current rate (doesn't count in rate limit)

func (*GithubDownloaderV3) SetContext Uses

func (g *GithubDownloaderV3) SetContext(ctx context.Context)

SetContext set context

type GithubDownloaderV3Factory Uses

type GithubDownloaderV3Factory struct {
}

GithubDownloaderV3Factory defines a github downloader v3 factory

func (*GithubDownloaderV3Factory) GitServiceType Uses

func (f *GithubDownloaderV3Factory) GitServiceType() structs.GitServiceType

GitServiceType returns the type of git service

func (*GithubDownloaderV3Factory) New Uses

func (f *GithubDownloaderV3Factory) New(ctx context.Context, opts base.MigrateOptions) (base.Downloader, error)

New returns a Downloader related to this factory according MigrateOptions

type GitlabDownloader Uses

type GitlabDownloader struct {
    base.NullDownloader
    // contains filtered or unexported fields
}

GitlabDownloader implements a Downloader interface to get repository informations from gitlab via go-gitlab - issueCount is incremented in GetIssues() to ensure PR and Issue numbers do not overlap, because Gitlab has individual Issue and Pull Request numbers. - issueSeen, working alongside issueCount, is checked in GetComments() to see whether we need to fetch the Issue or PR comments, as Gitlab stores them separately.

func NewGitlabDownloader Uses

func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, password, token string) (*GitlabDownloader, error)

NewGitlabDownloader creates a gitlab Downloader via gitlab API

Use either a username/password, personal token entered into the username field, or anonymous/public access
Note: Public access only allows very basic access

func (*GitlabDownloader) GetComments Uses

func (g *GitlabDownloader) GetComments(issueNumber int64) ([]*base.Comment, error)

GetComments returns comments according issueNumber TODO: figure out how to transfer comment reactions

func (*GitlabDownloader) GetIssues Uses

func (g *GitlabDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, error)

GetIssues returns issues according start and limit

Note: issue label description and colors are not supported by the go-gitlab library at this time

func (*GitlabDownloader) GetLabels Uses

func (g *GitlabDownloader) GetLabels() ([]*base.Label, error)

GetLabels returns labels

func (*GitlabDownloader) GetMilestones Uses

func (g *GitlabDownloader) GetMilestones() ([]*base.Milestone, error)

GetMilestones returns milestones

func (*GitlabDownloader) GetPullRequests Uses

func (g *GitlabDownloader) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)

GetPullRequests returns pull requests according page and perPage

func (*GitlabDownloader) GetReleases Uses

func (g *GitlabDownloader) GetReleases() ([]*base.Release, error)

GetReleases returns releases

func (*GitlabDownloader) GetRepoInfo Uses

func (g *GitlabDownloader) GetRepoInfo() (*base.Repository, error)

GetRepoInfo returns a repository information

func (*GitlabDownloader) GetReviews Uses

func (g *GitlabDownloader) GetReviews(pullRequestNumber int64) ([]*base.Review, error)

GetReviews returns pull requests review

func (*GitlabDownloader) GetTopics Uses

func (g *GitlabDownloader) GetTopics() ([]string, error)

GetTopics return gitlab topics

func (*GitlabDownloader) SetContext Uses

func (g *GitlabDownloader) SetContext(ctx context.Context)

SetContext set context

type GitlabDownloaderFactory Uses

type GitlabDownloaderFactory struct {
}

GitlabDownloaderFactory defines a gitlab downloader factory

func (*GitlabDownloaderFactory) GitServiceType Uses

func (f *GitlabDownloaderFactory) GitServiceType() structs.GitServiceType

GitServiceType returns the type of git service

func (*GitlabDownloaderFactory) New Uses

func (f *GitlabDownloaderFactory) New(ctx context.Context, opts base.MigrateOptions) (base.Downloader, error)

New returns a Downloader related to this factory according MigrateOptions

type GogsDownloader Uses

type GogsDownloader struct {
    base.NullDownloader
    // contains filtered or unexported fields
}

GogsDownloader implements a Downloader interface to get repository informations from gogs via API

func NewGogsDownloader Uses

func NewGogsDownloader(ctx context.Context, baseURL, userName, password, token, repoOwner, repoName string) *GogsDownloader

NewGogsDownloader creates a gogs Downloader via gogs API

func (*GogsDownloader) FormatCloneURL Uses

func (g *GogsDownloader) FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error)

FormatCloneURL add authentification into remote URLs

func (*GogsDownloader) GetComments Uses

func (g *GogsDownloader) GetComments(issueNumber int64) ([]*base.Comment, error)

GetComments returns comments according issueNumber

func (*GogsDownloader) GetIssues Uses

func (g *GogsDownloader) GetIssues(page, _ int) ([]*base.Issue, bool, error)

GetIssues returns issues according start and limit, perPage is not supported

func (*GogsDownloader) GetLabels Uses

func (g *GogsDownloader) GetLabels() ([]*base.Label, error)

GetLabels returns labels

func (*GogsDownloader) GetMilestones Uses

func (g *GogsDownloader) GetMilestones() ([]*base.Milestone, error)

GetMilestones returns milestones

func (*GogsDownloader) GetRepoInfo Uses

func (g *GogsDownloader) GetRepoInfo() (*base.Repository, error)

GetRepoInfo returns a repository information

func (*GogsDownloader) GetTopics Uses

func (g *GogsDownloader) GetTopics() ([]string, error)

GetTopics return repository topics

func (*GogsDownloader) RoundTrip Uses

func (g *GogsDownloader) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip wraps the provided request within this downloader's context and passes it to our internal http.Transport. This implements http.RoundTripper and makes the gogs client requests cancellable even though it is not cancellable itself

func (*GogsDownloader) SetContext Uses

func (g *GogsDownloader) SetContext(ctx context.Context)

SetContext set context

type GogsDownloaderFactory Uses

type GogsDownloaderFactory struct {
}

GogsDownloaderFactory defines a gogs downloader factory

func (*GogsDownloaderFactory) GitServiceType Uses

func (f *GogsDownloaderFactory) GitServiceType() structs.GitServiceType

GitServiceType returns the type of git service

func (*GogsDownloaderFactory) New Uses

func (f *GogsDownloaderFactory) New(ctx context.Context, opts base.MigrateOptions) (base.Downloader, error)

New returns a Downloader related to this factory according MigrateOptions

type MigrateOptions Uses

type MigrateOptions = base.MigrateOptions

MigrateOptions is equal to base.MigrateOptions

type PlainGitDownloader Uses

type PlainGitDownloader struct {
    base.NullDownloader
    // contains filtered or unexported fields
}

PlainGitDownloader implements a Downloader interface to clone git from a http/https URL

func NewPlainGitDownloader Uses

func NewPlainGitDownloader(ownerName, repoName, remoteURL string) *PlainGitDownloader

NewPlainGitDownloader creates a git Downloader

func (*PlainGitDownloader) GetRepoInfo Uses

func (g *PlainGitDownloader) GetRepoInfo() (*base.Repository, error)

GetRepoInfo returns a repository information

func (PlainGitDownloader) GetTopics Uses

func (g PlainGitDownloader) GetTopics() ([]string, error)

GetTopics return empty string slice

func (*PlainGitDownloader) SetContext Uses

func (g *PlainGitDownloader) SetContext(ctx context.Context)

SetContext set context

type RepositoryDumper Uses

type RepositoryDumper struct {
    // contains filtered or unexported fields
}

RepositoryDumper implements an Uploader to the local directory

func NewRepositoryDumper Uses

func NewRepositoryDumper(ctx context.Context, baseDir, repoOwner, repoName string, opts base.MigrateOptions) (*RepositoryDumper, error)

NewRepositoryDumper creates an gitea Uploader

func (*RepositoryDumper) Close Uses

func (g *RepositoryDumper) Close()

Close closes this uploader

func (*RepositoryDumper) CreateComments Uses

func (g *RepositoryDumper) CreateComments(comments ...*base.Comment) error

CreateComments creates comments of issues

func (*RepositoryDumper) CreateIssues Uses

func (g *RepositoryDumper) CreateIssues(issues ...*base.Issue) error

CreateIssues creates issues

func (*RepositoryDumper) CreateLabels Uses

func (g *RepositoryDumper) CreateLabels(labels ...*base.Label) error

CreateLabels creates labels

func (*RepositoryDumper) CreateMilestones Uses

func (g *RepositoryDumper) CreateMilestones(milestones ...*base.Milestone) error

CreateMilestones creates milestones

func (*RepositoryDumper) CreatePullRequests Uses

func (g *RepositoryDumper) CreatePullRequests(prs ...*base.PullRequest) error

CreatePullRequests creates pull requests

func (*RepositoryDumper) CreateReleases Uses

func (g *RepositoryDumper) CreateReleases(releases ...*base.Release) error

CreateReleases creates releases

func (*RepositoryDumper) CreateRepo Uses

func (g *RepositoryDumper) CreateRepo(repo *base.Repository, opts base.MigrateOptions) error

CreateRepo creates a repository

func (*RepositoryDumper) CreateReviews Uses

func (g *RepositoryDumper) CreateReviews(reviews ...*base.Review) error

CreateReviews create pull request reviews

func (*RepositoryDumper) CreateTopics Uses

func (g *RepositoryDumper) CreateTopics(topics ...string) error

CreateTopics creates topics

func (*RepositoryDumper) Finish Uses

func (g *RepositoryDumper) Finish() error

Finish when migrating succeed, this will update something.

func (*RepositoryDumper) MaxBatchInsertSize Uses

func (g *RepositoryDumper) MaxBatchInsertSize(tp string) int

MaxBatchInsertSize returns the table's max batch insert size

func (*RepositoryDumper) Rollback Uses

func (g *RepositoryDumper) Rollback() error

Rollback when migrating failed, this will rollback all the changes.

func (*RepositoryDumper) SyncTags Uses

func (g *RepositoryDumper) SyncTags() error

SyncTags syncs releases with tags in the database

type RepositoryRestorer Uses

type RepositoryRestorer struct {
    base.NullDownloader
    // contains filtered or unexported fields
}

RepositoryRestorer implements an Downloader from the local directory

func NewRepositoryRestorer Uses

func NewRepositoryRestorer(ctx context.Context, baseDir string, owner, repoName string) (*RepositoryRestorer, error)

NewRepositoryRestorer creates a repository restorer which could restore repository from a dumped folder

func (*RepositoryRestorer) GetComments Uses

func (r *RepositoryRestorer) GetComments(issueNumber int64) ([]*base.Comment, error)

GetComments returns comments according issueNumber

func (*RepositoryRestorer) GetIssues Uses

func (r *RepositoryRestorer) GetIssues(page, perPage int) ([]*base.Issue, bool, error)

GetIssues returns issues according start and limit

func (*RepositoryRestorer) GetLabels Uses

func (r *RepositoryRestorer) GetLabels() ([]*base.Label, error)

GetLabels returns labels

func (*RepositoryRestorer) GetMilestones Uses

func (r *RepositoryRestorer) GetMilestones() ([]*base.Milestone, error)

GetMilestones returns milestones

func (*RepositoryRestorer) GetPullRequests Uses

func (r *RepositoryRestorer) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)

GetPullRequests returns pull requests according page and perPage

func (*RepositoryRestorer) GetReleases Uses

func (r *RepositoryRestorer) GetReleases() ([]*base.Release, error)

GetReleases returns releases

func (*RepositoryRestorer) GetRepoInfo Uses

func (r *RepositoryRestorer) GetRepoInfo() (*base.Repository, error)

GetRepoInfo returns a repository information

func (*RepositoryRestorer) GetReviews Uses

func (r *RepositoryRestorer) GetReviews(pullRequestNumber int64) ([]*base.Review, error)

GetReviews returns pull requests review

func (*RepositoryRestorer) GetTopics Uses

func (r *RepositoryRestorer) GetTopics() ([]string, error)

GetTopics return github topics

func (*RepositoryRestorer) SetContext Uses

func (r *RepositoryRestorer) SetContext(ctx context.Context)

SetContext set context

Directories

PathSynopsis
base

Package migrations imports 36 packages (graph) and is imported by 20 packages. Updated 2021-01-22. Refresh now. Tools for package owners.