 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
- func IsErrNotSupported(err error) bool
- func Load(filename string, data any, validation bool) error
- func NilMessenger(string, ...any)
- type Comment
- type Commentable
- type Downloader
- type DownloaderContext
- type DownloaderFactory
- type ErrNotSupported
- type Issue
- type Label
- type Messenger
- type MigrateOptions
- type Milestone
- type NullDownloader
- func (n NullDownloader) FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error)
- func (n NullDownloader) GetAllComments(_ context.Context, page, perPage int) ([]*Comment, bool, error)
- func (n NullDownloader) GetComments(_ context.Context, commentable Commentable) ([]*Comment, bool, error)
- func (n NullDownloader) GetIssues(_ context.Context, page, perPage int) ([]*Issue, bool, error)
- func (n NullDownloader) GetLabels(_ context.Context) ([]*Label, error)
- func (n NullDownloader) GetMilestones(_ context.Context) ([]*Milestone, error)
- func (n NullDownloader) GetPullRequests(_ context.Context, page, perPage int) ([]*PullRequest, bool, error)
- func (n NullDownloader) GetReleases(_ context.Context) ([]*Release, error)
- func (n NullDownloader) GetRepoInfo(_ context.Context) (*Repository, error)
- func (n NullDownloader) GetReviews(_ context.Context, reviewable Reviewable) ([]*Review, error)
- func (n NullDownloader) GetTopics(_ context.Context) ([]string, error)
- func (n NullDownloader) SupportGetRepoComments() bool
 
- type PullRequest
- func (p *PullRequest) GetContext() DownloaderContext
- func (p *PullRequest) GetExternalID() int64
- func (p *PullRequest) GetExternalName() string
- func (p *PullRequest) GetForeignIndex() int64
- func (p PullRequest) GetGitHeadRefName() string
- func (p *PullRequest) GetLocalIndex() int64
- func (p *PullRequest) IsForkPullRequest() bool
 
- type PullRequestBranch
- type Reaction
- type Release
- type ReleaseAsset
- type Repository
- type RetryDownloader
- func (d *RetryDownloader) GetComments(ctx context.Context, commentable Commentable) ([]*Comment, bool, error)
- func (d *RetryDownloader) GetIssues(ctx context.Context, page, perPage int) ([]*Issue, bool, error)
- func (d *RetryDownloader) GetLabels(ctx context.Context) ([]*Label, error)
- func (d *RetryDownloader) GetMilestones(ctx context.Context) ([]*Milestone, error)
- func (d *RetryDownloader) GetPullRequests(ctx context.Context, page, perPage int) ([]*PullRequest, bool, error)
- func (d *RetryDownloader) GetReleases(ctx context.Context) ([]*Release, error)
- func (d *RetryDownloader) GetRepoInfo(ctx context.Context) (*Repository, error)
- func (d *RetryDownloader) GetReviews(ctx context.Context, reviewable Reviewable) ([]*Review, error)
- func (d *RetryDownloader) GetTopics(ctx context.Context) ([]string, error)
 
- type Review
- type ReviewComment
- type Reviewable
- type Uploader
Constants ¶
const ( ReviewStatePending = "PENDING" ReviewStateApproved = "APPROVED" ReviewStateChangesRequested = "CHANGES_REQUESTED" ReviewStateCommented = "COMMENTED" ReviewStateRequestReview = "REQUEST_REVIEW" )
enumerate all review states
Variables ¶
This section is empty.
Functions ¶
func IsErrNotSupported ¶
IsErrNotSupported checks if an error is an ErrNotSupported
func NilMessenger ¶
NilMessenger represents an empty formatting function
Types ¶
type Comment ¶
type Comment struct {
	IssueIndex  int64 `yaml:"issue_index"`
	Index       int64
	CommentType string `yaml:"comment_type"` // see `commentStrings` in models/issues/comment.go
	PosterID    int64  `yaml:"poster_id"`
	PosterName  string `yaml:"poster_name"`
	PosterEmail string `yaml:"poster_email"`
	Created     time.Time
	Updated     time.Time
	Content     string
	Reactions   []*Reaction
	Meta        map[string]any `yaml:"meta,omitempty"` // see models/issues/comment.go for fields in Comment struct
}
    Comment is a standard comment information
func (*Comment) GetExternalID ¶ added in v1.17.0
ExternalID ExternalUserMigrated interface
func (*Comment) GetExternalName ¶ added in v1.17.0
GetExternalName ExternalUserMigrated interface
type Commentable ¶ added in v1.17.0
type Commentable interface {
	Reviewable
	GetContext() DownloaderContext
}
    Commentable can be commented upon
type Downloader ¶
type Downloader interface {
	GetRepoInfo(ctx context.Context) (*Repository, error)
	GetTopics(ctx context.Context) ([]string, error)
	GetMilestones(ctx context.Context) ([]*Milestone, error)
	GetReleases(ctx context.Context) ([]*Release, error)
	GetLabels(ctx context.Context) ([]*Label, error)
	GetIssues(ctx context.Context, page, perPage int) ([]*Issue, bool, error)
	GetComments(ctx context.Context, commentable Commentable) ([]*Comment, bool, error)
	GetAllComments(ctx context.Context, page, perPage int) ([]*Comment, bool, error)
	SupportGetRepoComments() bool
	GetPullRequests(ctx context.Context, page, perPage int) ([]*PullRequest, bool, error)
	GetReviews(ctx context.Context, reviewable Reviewable) ([]*Review, error)
	FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error)
}
    Downloader downloads the site repo information
type DownloaderContext ¶ added in v1.17.0
type DownloaderContext any
DownloaderContext has opaque information only relevant to a given downloader
type DownloaderFactory ¶
type DownloaderFactory interface {
	New(ctx context.Context, opts MigrateOptions) (Downloader, error)
	GitServiceType() structs.GitServiceType
}
    DownloaderFactory defines an interface to match a downloader implementation and create a downloader
type ErrNotSupported ¶
type ErrNotSupported struct {
	Entity string
}
    ErrNotSupported represents status if a downloader do not supported something.
type Issue ¶
type Issue struct {
	Number       int64             `json:"number"`
	PosterID     int64             `yaml:"poster_id" json:"poster_id"`
	PosterName   string            `yaml:"poster_name" json:"poster_name"`
	PosterEmail  string            `yaml:"poster_email" json:"poster_email"`
	Title        string            `json:"title"`
	Content      string            `json:"content"`
	Ref          string            `json:"ref"`
	Milestone    string            `json:"milestone"`
	State        string            `json:"state"` // closed, open
	IsLocked     bool              `yaml:"is_locked" json:"is_locked"`
	Created      time.Time         `json:"created"`
	Updated      time.Time         `json:"updated"`
	Closed       *time.Time        `json:"closed"`
	Labels       []*Label          `json:"labels"`
	Reactions    []*Reaction       `json:"reactions"`
	Assignees    []string          `json:"assignees"`
	ForeignIndex int64             `json:"foreign_id"`
	Context      DownloaderContext `yaml:"-"`
}
    Issue is a standard issue information
func (*Issue) GetContext ¶ added in v1.17.0
func (issue *Issue) GetContext() DownloaderContext
func (*Issue) GetExternalID ¶ added in v1.17.0
GetExternalID ExternalUserMigrated interface
func (*Issue) GetExternalName ¶ added in v1.17.0
GetExternalName ExternalUserMigrated interface
func (*Issue) GetForeignIndex ¶ added in v1.17.0
func (*Issue) GetLocalIndex ¶ added in v1.17.0
type Label ¶
type Label struct {
	Name        string `json:"name"`
	Color       string `json:"color"`
	Description string `json:"description"`
	Exclusive   bool   `json:"exclusive"`
}
    Label defines a standard label information
type MigrateOptions ¶
type MigrateOptions struct {
	// required: true
	CloneAddr             string `json:"clone_addr" binding:"Required"`
	CloneAddrEncrypted    string `json:"clone_addr_encrypted,omitempty"`
	AuthUsername          string `json:"auth_username"`
	AuthPassword          string `json:"-"`
	AuthPasswordEncrypted string `json:"auth_password_encrypted,omitempty"`
	AuthToken             string `json:"-"`
	AuthTokenEncrypted    string `json:"auth_token_encrypted,omitempty"`
	// required: true
	UID int `json:"uid" binding:"Required"`
	// required: true
	RepoName        string `json:"repo_name" binding:"Required"`
	Mirror          bool   `json:"mirror"`
	LFS             bool   `json:"lfs"`
	LFSEndpoint     string `json:"lfs_endpoint"`
	Private         bool   `json:"private"`
	Description     string `json:"description"`
	OriginalURL     string
	GitServiceType  structs.GitServiceType
	Wiki            bool
	Issues          bool
	Milestones      bool
	Labels          bool
	Releases        bool
	Comments        bool
	PullRequests    bool
	ReleaseAssets   bool
	MigrateToRepoID int64
	MirrorInterval  string `json:"mirror_interval"`
	AWSAccessKeyID     string
	AWSSecretAccessKey string
}
    MigrateOptions defines the way a repository gets migrated this is for internal usage by migrations module and func who interact with it
type Milestone ¶
type Milestone struct {
	Title       string     `json:"title"`
	Description string     `json:"description"`
	Deadline    *time.Time `json:"deadline"`
	Created     time.Time  `json:"created"`
	Updated     *time.Time `json:"updated"`
	Closed      *time.Time `json:"closed"`
	State       string     `json:"state"` // open, closed
}
    Milestone defines a standard milestone
type NullDownloader ¶
type NullDownloader struct{}
    NullDownloader implements a blank downloader
func (NullDownloader) FormatCloneURL ¶
func (n NullDownloader) FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error)
FormatCloneURL add authentication into remote URLs
func (NullDownloader) GetAllComments ¶ added in v1.17.0
func (n NullDownloader) GetAllComments(_ context.Context, page, perPage int) ([]*Comment, bool, error)
GetAllComments returns paginated comments
func (NullDownloader) GetComments ¶
func (n NullDownloader) GetComments(_ context.Context, commentable Commentable) ([]*Comment, bool, error)
GetComments returns comments of an issue or PR
func (NullDownloader) GetLabels ¶
func (n NullDownloader) GetLabels(_ context.Context) ([]*Label, error)
GetLabels returns labels
func (NullDownloader) GetMilestones ¶
func (n NullDownloader) GetMilestones(_ context.Context) ([]*Milestone, error)
GetMilestones returns milestones
func (NullDownloader) GetPullRequests ¶
func (n NullDownloader) GetPullRequests(_ context.Context, page, perPage int) ([]*PullRequest, bool, error)
GetPullRequests returns pull requests according page and perPage
func (NullDownloader) GetReleases ¶
func (n NullDownloader) GetReleases(_ context.Context) ([]*Release, error)
GetReleases returns releases
func (NullDownloader) GetRepoInfo ¶
func (n NullDownloader) GetRepoInfo(_ context.Context) (*Repository, error)
GetRepoInfo returns a repository information
func (NullDownloader) GetReviews ¶
func (n NullDownloader) GetReviews(_ context.Context, reviewable Reviewable) ([]*Review, error)
GetReviews returns pull requests review
func (NullDownloader) GetTopics ¶
func (n NullDownloader) GetTopics(_ context.Context) ([]string, error)
GetTopics return repository topics
func (NullDownloader) SupportGetRepoComments ¶
func (n NullDownloader) SupportGetRepoComments() bool
SupportGetRepoComments return true if it supports get repo comments
type PullRequest ¶
type PullRequest struct {
	Number         int64
	Title          string
	PosterName     string `yaml:"poster_name"`
	PosterID       int64  `yaml:"poster_id"`
	PosterEmail    string `yaml:"poster_email"`
	Content        string
	Milestone      string
	State          string
	Created        time.Time
	Updated        time.Time
	Closed         *time.Time
	Labels         []*Label
	PatchURL       string `yaml:"patch_url"` // SECURITY: This must be safe to download directly from
	Merged         bool
	MergedTime     *time.Time `yaml:"merged_time"`
	MergeCommitSHA string     `yaml:"merge_commit_sha"`
	Head           PullRequestBranch
	Base           PullRequestBranch
	Assignees      []string
	IsLocked       bool `yaml:"is_locked"`
	Reactions      []*Reaction
	ForeignIndex   int64
	Context        DownloaderContext `yaml:"-"`
	EnsuredSafe    bool              `yaml:"ensured_safe"`
	IsDraft        bool              `yaml:"is_draft"`
}
    PullRequest defines a standard pull request information
func (*PullRequest) GetContext ¶ added in v1.17.0
func (p *PullRequest) GetContext() DownloaderContext
func (*PullRequest) GetExternalID ¶ added in v1.17.0
func (p *PullRequest) GetExternalID() int64
ExternalID ExternalUserMigrated interface
func (*PullRequest) GetExternalName ¶ added in v1.17.0
func (p *PullRequest) GetExternalName() string
GetExternalName ExternalUserMigrated interface
func (*PullRequest) GetForeignIndex ¶ added in v1.17.0
func (p *PullRequest) GetForeignIndex() int64
func (PullRequest) GetGitHeadRefName ¶ added in v1.25.0
func (p PullRequest) GetGitHeadRefName() string
GetGitHeadRefName returns pull request relative path to head
func (*PullRequest) GetLocalIndex ¶ added in v1.17.0
func (p *PullRequest) GetLocalIndex() int64
func (*PullRequest) IsForkPullRequest ¶
func (p *PullRequest) IsForkPullRequest() bool
IsForkPullRequest returns true if the pull request from a forked repository but not the same repository
type PullRequestBranch ¶
type PullRequestBranch struct {
	CloneURL  string `yaml:"clone_url"` // SECURITY: This must be safe to download from
	Ref       string // SECURITY: this must be a git.IsValidRefPattern
	SHA       string // SECURITY: this must be a git.IsValidSHAPattern
	RepoName  string `yaml:"repo_name"`
	OwnerName string `yaml:"owner_name"`
}
    PullRequestBranch represents a pull request branch
func (PullRequestBranch) RepoFullName ¶ added in v1.23.0
func (p PullRequestBranch) RepoFullName() string
RepoFullName returns pull request repo full name
type Reaction ¶
type Reaction struct {
	UserID   int64  `yaml:"user_id" json:"user_id"`
	UserName string `yaml:"user_name" json:"user_name"`
	Content  string `json:"content"`
}
    Reaction represents a reaction to an issue/pr/comment.
func (*Reaction) GetExternalID ¶ added in v1.17.0
GetExternalID ExternalUserMigrated interface
func (*Reaction) GetExternalName ¶ added in v1.17.0
GetExternalName ExternalUserMigrated interface
type Release ¶
type Release struct {
	TagName         string `yaml:"tag_name"`         // SECURITY: This must pass git.IsValidRefPattern
	TargetCommitish string `yaml:"target_commitish"` // SECURITY: This must pass git.IsValidRefPattern
	Name            string
	Body            string
	Draft           bool
	Prerelease      bool
	PublisherID     int64  `yaml:"publisher_id"`
	PublisherName   string `yaml:"publisher_name"`
	PublisherEmail  string `yaml:"publisher_email"`
	Assets          []*ReleaseAsset
	Created         time.Time
	Published       time.Time
}
    Release represents a release
func (*Release) GetExternalID ¶ added in v1.17.0
GetExternalID ExternalUserMigrated interface
func (*Release) GetExternalName ¶ added in v1.17.0
GetExternalName ExternalUserMigrated interface
type ReleaseAsset ¶
type ReleaseAsset struct {
	ID            int64
	Name          string
	ContentType   *string `yaml:"content_type"`
	Size          *int
	DownloadCount *int `yaml:"download_count"`
	Created       time.Time
	Updated       time.Time
	DownloadURL *string `yaml:"download_url"` // SECURITY: It is the responsibility of downloader to make sure this is safe
	// if DownloadURL is nil, the function should be invoked
	DownloadFunc func() (io.ReadCloser, error) `yaml:"-"` // SECURITY: It is the responsibility of downloader to make sure this is safe
}
    ReleaseAsset represents a release asset
type Repository ¶
type Repository struct {
	Name          string
	Owner         string
	IsPrivate     bool `yaml:"is_private"`
	IsMirror      bool `yaml:"is_mirror"`
	Description   string
	CloneURL      string `yaml:"clone_url"` // SECURITY: This must be checked to ensure that is safe to be used
	OriginalURL   string `yaml:"original_url"`
	DefaultBranch string
}
    Repository defines a standard repository information
type RetryDownloader ¶
type RetryDownloader struct {
	Downloader
	RetryTimes int // the total execute times
	RetryDelay int // time to delay seconds
}
    RetryDownloader retry the downloads
func NewRetryDownloader ¶
func NewRetryDownloader(downloader Downloader, retryTimes, retryDelay int) *RetryDownloader
NewRetryDownloader creates a retry downloader
func (*RetryDownloader) GetComments ¶
func (d *RetryDownloader) GetComments(ctx context.Context, commentable Commentable) ([]*Comment, bool, error)
GetComments returns a repository's comments with retry
func (*RetryDownloader) GetLabels ¶
func (d *RetryDownloader) GetLabels(ctx context.Context) ([]*Label, error)
GetLabels returns a repository's labels with retry
func (*RetryDownloader) GetMilestones ¶
func (d *RetryDownloader) GetMilestones(ctx context.Context) ([]*Milestone, error)
GetMilestones returns a repository's milestones with retry
func (*RetryDownloader) GetPullRequests ¶
func (d *RetryDownloader) GetPullRequests(ctx context.Context, page, perPage int) ([]*PullRequest, bool, error)
GetPullRequests returns a repository's pull requests with retry
func (*RetryDownloader) GetReleases ¶
func (d *RetryDownloader) GetReleases(ctx context.Context) ([]*Release, error)
GetReleases returns a repository's releases with retry
func (*RetryDownloader) GetRepoInfo ¶
func (d *RetryDownloader) GetRepoInfo(ctx context.Context) (*Repository, error)
GetRepoInfo returns a repository information with retry
func (*RetryDownloader) GetReviews ¶
func (d *RetryDownloader) GetReviews(ctx context.Context, reviewable Reviewable) ([]*Review, error)
GetReviews returns pull requests reviews
type Review ¶
type Review struct {
	ID           int64
	IssueIndex   int64  `yaml:"issue_index"`
	ReviewerID   int64  `yaml:"reviewer_id"`
	ReviewerName string `yaml:"reviewer_name"`
	Official     bool
	CommitID     string `yaml:"commit_id"`
	Content      string
	CreatedAt    time.Time `yaml:"created_at"`
	State        string    // PENDING, APPROVED, REQUEST_CHANGES, or COMMENT
	Comments     []*ReviewComment
}
    Review is a standard review information
func (*Review) GetExternalID ¶ added in v1.17.0
GetExternalID ExternalUserMigrated interface
func (*Review) GetExternalName ¶ added in v1.17.0
GetExternalName ExternalUserMigrated interface
type ReviewComment ¶
type ReviewComment struct {
	ID        int64
	InReplyTo int64 `yaml:"in_reply_to"`
	Content   string
	TreePath  string `yaml:"tree_path"`
	DiffHunk  string `yaml:"diff_hunk"`
	Position  int
	Line      int
	CommitID  string `yaml:"commit_id"`
	PosterID  int64  `yaml:"poster_id"`
	Reactions []*Reaction
	CreatedAt time.Time `yaml:"created_at"`
	UpdatedAt time.Time `yaml:"updated_at"`
}
    ReviewComment represents a review comment
type Reviewable ¶ added in v1.17.0
type Reviewable interface {
	GetLocalIndex() int64
	// GetForeignIndex presents the foreign index, which could be misused:
	// For example, if there are 2 Gitea sites: site-A exports a dataset, then site-B imports it:
	// * if site-A exports files by using its LocalIndex
	// * from site-A's view, LocalIndex is site-A's IssueIndex while ForeignIndex is site-B's IssueIndex
	// * but from site-B's view, LocalIndex is site-B's IssueIndex while ForeignIndex is site-A's IssueIndex
	//
	// So the exporting/importing must be paired, but the meaning of them looks confusing then:
	// * either site-A and site-B both use LocalIndex during dumping/restoring
	// * or site-A and site-B both use ForeignIndex
	GetForeignIndex() int64
}
    Reviewable can be reviewed
type Uploader ¶
type Uploader interface {
	MaxBatchInsertSize(tp string) int
	CreateRepo(ctx context.Context, repo *Repository, opts MigrateOptions) error
	CreateTopics(ctx context.Context, topic ...string) error
	CreateMilestones(ctx context.Context, milestones ...*Milestone) error
	CreateReleases(ctx context.Context, releases ...*Release) error
	SyncTags(ctx context.Context) error
	CreateLabels(ctx context.Context, labels ...*Label) error
	CreateIssues(ctx context.Context, issues ...*Issue) error
	CreateComments(ctx context.Context, comments ...*Comment) error
	CreatePullRequests(ctx context.Context, prs ...*PullRequest) error
	CreateReviews(ctx context.Context, reviews ...*Review) error
	Rollback() error
	Finish(ctx context.Context) error
	Close()
}
    Uploader uploads all the information of one repository