import "code.gitea.io/gitea/modules/migrations"
dump.go error.go git.go gitea_downloader.go gitea_uploader.go github.go gitlab.go gogs.go migrate.go restore.go update.go
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(ctx context.Context, baseDir, ownerName string, opts base.MigrateOptions) error
DumpRepository dump repository according MigrateOptions to a local directory
Init migrations service
IsRateLimitError returns true if the err is github.RateLimitError
IsTwoFactorAuthError returns true if the err is github.TwoFactorAuthError
func MigrateRepository(ctx context.Context, doer *models.User, ownerName string, opts base.MigrateOptions) (*models.Repository, error)
MigrateRepository migrate repository according MigrateOptions
func RegisterDownloaderFactory(factory base.DownloaderFactory)
RegisterDownloaderFactory registers a downloader factory
RestoreRepository restore a repository from the disk directory
UpdateMigrationPosterID updates all migrated repositories' issues and comments posterID
type GiteaDownloader struct { base.NullDownloader // contains filtered or unexported fields }
GiteaDownloader implements a Downloader interface to get repository information's
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
GetComments returns comments according issueNumber
GetIssues returns issues according start and limit
func (g *GiteaDownloader) GetLabels() ([]*base.Label, error)
GetLabels returns labels
func (g *GiteaDownloader) GetMilestones() ([]*base.Milestone, error)
GetMilestones returns milestones
func (g *GiteaDownloader) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)
GetPullRequests returns pull requests according page and perPage
func (g *GiteaDownloader) GetReleases() ([]*base.Release, error)
GetReleases returns releases
func (g *GiteaDownloader) GetRepoInfo() (*base.Repository, error)
GetRepoInfo returns a repository information
GetReviews returns pull requests review
func (g *GiteaDownloader) GetTopics() ([]string, error)
GetTopics return gitea topics
func (g *GiteaDownloader) SetContext(ctx context.Context)
SetContext set context
type GiteaDownloaderFactory struct { }
GiteaDownloaderFactory defines a gitea downloader factory
func (f *GiteaDownloaderFactory) GitServiceType() structs.GitServiceType
GitServiceType returns the type of git service
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 struct {
// contains filtered or unexported fields
}
GiteaLocalUploader implements an Uploader to gitea sites
func NewGiteaLocalUploader(ctx context.Context, doer *models.User, repoOwner, repoName string) *GiteaLocalUploader
NewGiteaLocalUploader creates an gitea Uploader via gitea API v1
func (g *GiteaLocalUploader) Close()
Close closes this uploader
func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error
CreateComments creates comments of issues
func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error
CreateIssues creates issues
func (g *GiteaLocalUploader) CreateLabels(labels ...*base.Label) error
CreateLabels creates labels
func (g *GiteaLocalUploader) CreateMilestones(milestones ...*base.Milestone) error
CreateMilestones creates milestones
func (g *GiteaLocalUploader) CreatePullRequests(prs ...*base.PullRequest) error
CreatePullRequests creates pull requests
func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error
CreateReleases creates releases
func (g *GiteaLocalUploader) CreateRepo(repo *base.Repository, opts base.MigrateOptions) error
CreateRepo creates a repository
func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error
CreateReviews create pull request reviews
func (g *GiteaLocalUploader) CreateTopics(topics ...string) error
CreateTopics creates topics
func (g *GiteaLocalUploader) Finish() error
Finish when migrating success, this will do some status update things.
func (g *GiteaLocalUploader) MaxBatchInsertSize(tp string) int
MaxBatchInsertSize returns the table's max batch insert size
func (g *GiteaLocalUploader) Rollback() error
Rollback when migrating failed, this will rollback all the changes.
func (g *GiteaLocalUploader) SyncTags() error
SyncTags syncs releases with tags in the database
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(ctx context.Context, baseURL, userName, password, token, repoOwner, repoName string) *GithubDownloaderV3
NewGithubDownloaderV3 creates a github Downloader via github v3 API
GetComments returns comments according issueNumber
GetIssues returns issues according start and limit
func (g *GithubDownloaderV3) GetLabels() ([]*base.Label, error)
GetLabels returns labels
func (g *GithubDownloaderV3) GetMilestones() ([]*base.Milestone, error)
GetMilestones returns milestones
func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)
GetPullRequests returns pull requests according page and perPage
func (g *GithubDownloaderV3) GetReleases() ([]*base.Release, error)
GetReleases returns releases
func (g *GithubDownloaderV3) GetRepoInfo() (*base.Repository, error)
GetRepoInfo returns a repository information
GetReviews returns pull requests review
func (g *GithubDownloaderV3) GetTopics() ([]string, error)
GetTopics return github topics
func (g *GithubDownloaderV3) RefreshRate() error
RefreshRate update the current rate (doesn't count in rate limit)
func (g *GithubDownloaderV3) SetContext(ctx context.Context)
SetContext set context
type GithubDownloaderV3Factory struct { }
GithubDownloaderV3Factory defines a github downloader v3 factory
func (f *GithubDownloaderV3Factory) GitServiceType() structs.GitServiceType
GitServiceType returns the type of git service
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 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(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
GetComments returns comments according issueNumber TODO: figure out how to transfer comment reactions
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 (g *GitlabDownloader) GetLabels() ([]*base.Label, error)
GetLabels returns labels
func (g *GitlabDownloader) GetMilestones() ([]*base.Milestone, error)
GetMilestones returns milestones
func (g *GitlabDownloader) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)
GetPullRequests returns pull requests according page and perPage
func (g *GitlabDownloader) GetReleases() ([]*base.Release, error)
GetReleases returns releases
func (g *GitlabDownloader) GetRepoInfo() (*base.Repository, error)
GetRepoInfo returns a repository information
GetReviews returns pull requests review
func (g *GitlabDownloader) GetTopics() ([]string, error)
GetTopics return gitlab topics
func (g *GitlabDownloader) SetContext(ctx context.Context)
SetContext set context
type GitlabDownloaderFactory struct { }
GitlabDownloaderFactory defines a gitlab downloader factory
func (f *GitlabDownloaderFactory) GitServiceType() structs.GitServiceType
GitServiceType returns the type of git service
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 struct { base.NullDownloader // contains filtered or unexported fields }
GogsDownloader implements a Downloader interface to get repository informations from gogs via API
func NewGogsDownloader(ctx context.Context, baseURL, userName, password, token, repoOwner, repoName string) *GogsDownloader
NewGogsDownloader creates a gogs Downloader via gogs API
func (g *GogsDownloader) FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error)
FormatCloneURL add authentification into remote URLs
GetComments returns comments according issueNumber
GetIssues returns issues according start and limit, perPage is not supported
func (g *GogsDownloader) GetLabels() ([]*base.Label, error)
GetLabels returns labels
func (g *GogsDownloader) GetMilestones() ([]*base.Milestone, error)
GetMilestones returns milestones
func (g *GogsDownloader) GetRepoInfo() (*base.Repository, error)
GetRepoInfo returns a repository information
func (g *GogsDownloader) GetTopics() ([]string, error)
GetTopics return repository topics
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 (g *GogsDownloader) SetContext(ctx context.Context)
SetContext set context
type GogsDownloaderFactory struct { }
GogsDownloaderFactory defines a gogs downloader factory
func (f *GogsDownloaderFactory) GitServiceType() structs.GitServiceType
GitServiceType returns the type of git service
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 = base.MigrateOptions
MigrateOptions is equal to base.MigrateOptions
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(ownerName, repoName, remoteURL string) *PlainGitDownloader
NewPlainGitDownloader creates a git Downloader
func (g *PlainGitDownloader) GetRepoInfo() (*base.Repository, error)
GetRepoInfo returns a repository information
func (g PlainGitDownloader) GetTopics() ([]string, error)
GetTopics return empty string slice
func (g *PlainGitDownloader) SetContext(ctx context.Context)
SetContext set context
type RepositoryDumper struct {
// contains filtered or unexported fields
}
RepositoryDumper implements an Uploader to the local directory
func NewRepositoryDumper(ctx context.Context, baseDir, repoOwner, repoName string, opts base.MigrateOptions) (*RepositoryDumper, error)
NewRepositoryDumper creates an gitea Uploader
func (g *RepositoryDumper) Close()
Close closes this uploader
func (g *RepositoryDumper) CreateComments(comments ...*base.Comment) error
CreateComments creates comments of issues
func (g *RepositoryDumper) CreateIssues(issues ...*base.Issue) error
CreateIssues creates issues
func (g *RepositoryDumper) CreateLabels(labels ...*base.Label) error
CreateLabels creates labels
func (g *RepositoryDumper) CreateMilestones(milestones ...*base.Milestone) error
CreateMilestones creates milestones
func (g *RepositoryDumper) CreatePullRequests(prs ...*base.PullRequest) error
CreatePullRequests creates pull requests
func (g *RepositoryDumper) CreateReleases(releases ...*base.Release) error
CreateReleases creates releases
func (g *RepositoryDumper) CreateRepo(repo *base.Repository, opts base.MigrateOptions) error
CreateRepo creates a repository
func (g *RepositoryDumper) CreateReviews(reviews ...*base.Review) error
CreateReviews create pull request reviews
func (g *RepositoryDumper) CreateTopics(topics ...string) error
CreateTopics creates topics
func (g *RepositoryDumper) Finish() error
Finish when migrating succeed, this will update something.
func (g *RepositoryDumper) MaxBatchInsertSize(tp string) int
MaxBatchInsertSize returns the table's max batch insert size
func (g *RepositoryDumper) Rollback() error
Rollback when migrating failed, this will rollback all the changes.
func (g *RepositoryDumper) SyncTags() error
SyncTags syncs releases with tags in the database
type RepositoryRestorer struct { base.NullDownloader // contains filtered or unexported fields }
RepositoryRestorer implements an Downloader from the local directory
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
GetComments returns comments according issueNumber
GetIssues returns issues according start and limit
func (r *RepositoryRestorer) GetLabels() ([]*base.Label, error)
GetLabels returns labels
func (r *RepositoryRestorer) GetMilestones() ([]*base.Milestone, error)
GetMilestones returns milestones
func (r *RepositoryRestorer) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)
GetPullRequests returns pull requests according page and perPage
func (r *RepositoryRestorer) GetReleases() ([]*base.Release, error)
GetReleases returns releases
func (r *RepositoryRestorer) GetRepoInfo() (*base.Repository, error)
GetRepoInfo returns a repository information
GetReviews returns pull requests review
func (r *RepositoryRestorer) GetTopics() ([]string, error)
GetTopics return github topics
func (r *RepositoryRestorer) SetContext(ctx context.Context)
SetContext set context
Path | Synopsis |
---|---|
base |
Package migrations imports 36 packages (graph) and is imported by 20 packages. Updated 2021-01-22. Refresh now. Tools for package owners.