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

package base

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

Index

Package Files

comment.go downloader.go error.go issue.go label.go milestone.go null_downloader.go options.go pullrequest.go reaction.go release.go repo.go retry_downloader.go review.go uploader.go

Constants

const (
    ReviewStatePending          = "PENDING"
    ReviewStateApproved         = "APPROVED"
    ReviewStateChangesRequested = "CHANGES_REQUESTED"
    ReviewStateCommented        = "COMMENTED"
)

enumerate all review states

func IsErrNotSupported Uses

func IsErrNotSupported(err error) bool

IsErrNotSupported checks if an error is an ErrNotSupported

type Comment Uses

type Comment struct {
    IssueIndex  int64  `yaml:"issue_index"`
    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
}

Comment is a standard comment information

type Downloader Uses

type Downloader interface {
    SetContext(context.Context)
    GetRepoInfo() (*Repository, error)
    GetTopics() ([]string, error)
    GetMilestones() ([]*Milestone, error)
    GetReleases() ([]*Release, error)
    GetLabels() ([]*Label, error)
    GetIssues(page, perPage int) ([]*Issue, bool, error)
    GetComments(issueNumber int64) ([]*Comment, error)
    GetPullRequests(page, perPage int) ([]*PullRequest, bool, error)
    GetReviews(pullRequestNumber int64) ([]*Review, error)
    FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error)
}

Downloader downloads the site repo informations

type DownloaderFactory Uses

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 Uses

type ErrNotSupported struct {
    Entity string
}

ErrNotSupported represents status if a downloader do not supported something.

func (ErrNotSupported) Error Uses

func (err ErrNotSupported) Error() string

Error return error message

type Issue Uses

type Issue struct {
    Number      int64
    PosterID    int64  `yaml:"poster_id"`
    PosterName  string `yaml:"poster_name"`
    PosterEmail string `yaml:"poster_email"`
    Title       string
    Content     string
    Ref         string
    Milestone   string
    State       string // closed, open
    IsLocked    bool   `yaml:"is_locked"`
    Created     time.Time
    Updated     time.Time
    Closed      *time.Time
    Labels      []*Label
    Reactions   []*Reaction
    Assignees   []string
}

Issue is a standard issue information

type Label Uses

type Label struct {
    Name        string
    Color       string
    Description string
}

Label defines a standard label informations

type MigrateOptions Uses

type MigrateOptions struct {
    // required: true
    CloneAddr    string `json:"clone_addr" binding:"Required"`
    AuthUsername string `json:"auth_username"`
    AuthPassword string `json:"auth_password"`
    AuthToken    string `json:"auth_token"`
    // required: true
    UID int `json:"uid" binding:"Required"`
    // required: true
    RepoName        string `json:"repo_name" binding:"Required"`
    Mirror          bool   `json:"mirror"`
    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"`
}

MigrateOptions defines the way a repository gets migrated this is for internal usage by migrations module and func who interact with it

type Milestone Uses

type Milestone struct {
    Title       string
    Description string
    Deadline    *time.Time
    Created     time.Time
    Updated     *time.Time
    Closed      *time.Time
    State       string // open, closed
}

Milestone defines a standard milestone

type NullDownloader Uses

type NullDownloader struct {
}

NullDownloader implements a blank downloader

func (NullDownloader) FormatCloneURL Uses

func (n NullDownloader) FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error)

FormatCloneURL add authentification into remote URLs

func (NullDownloader) GetComments Uses

func (n NullDownloader) GetComments(issueNumber int64) ([]*Comment, error)

GetComments returns comments according issueNumber

func (NullDownloader) GetIssues Uses

func (n NullDownloader) GetIssues(page, perPage int) ([]*Issue, bool, error)

GetIssues returns issues according start and limit

func (NullDownloader) GetLabels Uses

func (n NullDownloader) GetLabels() ([]*Label, error)

GetLabels returns labels

func (NullDownloader) GetMilestones Uses

func (n NullDownloader) GetMilestones() ([]*Milestone, error)

GetMilestones returns milestones

func (NullDownloader) GetPullRequests Uses

func (n NullDownloader) GetPullRequests(page, perPage int) ([]*PullRequest, bool, error)

GetPullRequests returns pull requests according page and perPage

func (NullDownloader) GetReleases Uses

func (n NullDownloader) GetReleases() ([]*Release, error)

GetReleases returns releases

func (NullDownloader) GetRepoInfo Uses

func (n NullDownloader) GetRepoInfo() (*Repository, error)

GetRepoInfo returns a repository information

func (NullDownloader) GetReviews Uses

func (n NullDownloader) GetReviews(pullRequestNumber int64) ([]*Review, error)

GetReviews returns pull requests review

func (NullDownloader) GetTopics Uses

func (n NullDownloader) GetTopics() ([]string, error)

GetTopics return repository topics

func (NullDownloader) SetContext Uses

func (n NullDownloader) SetContext(_ context.Context)

SetContext set context

type PullRequest Uses

type PullRequest struct {
    Number         int64
    OriginalNumber int64 `yaml:"original_number"`
    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"`
    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
}

PullRequest defines a standard pull request information

func (*PullRequest) IsForkPullRequest Uses

func (p *PullRequest) IsForkPullRequest() bool

IsForkPullRequest returns true if the pull request from a forked repository but not the same repository

type PullRequestBranch Uses

type PullRequestBranch struct {
    CloneURL  string `yaml:"clone_url"`
    Ref       string
    SHA       string
    RepoName  string `yaml:"repo_name"`
    OwnerName string `yaml:"owner_name"`
}

PullRequestBranch represents a pull request branch

func (PullRequestBranch) RepoPath Uses

func (p PullRequestBranch) RepoPath() string

RepoPath returns pull request repo path

type Reaction Uses

type Reaction struct {
    UserID   int64  `yaml:"user_id"`
    UserName string `yaml:"user_name"`
    Content  string
}

Reaction represents a reaction to an issue/pr/comment.

type Release Uses

type Release struct {
    TagName         string `yaml:"tag_name"`
    TargetCommitish string `yaml:"target_commitish"`
    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

type ReleaseAsset Uses

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"`
    // if DownloadURL is nil, the function should be invoked
    DownloadFunc func() (io.ReadCloser, error) `yaml:"-"`
}

ReleaseAsset represents a release asset

type Repository Uses

type Repository struct {
    Name          string
    Owner         string
    IsPrivate     bool `yaml:"is_private"`
    IsMirror      bool `yaml:"is_mirror"`
    Description   string
    CloneURL      string `yaml:"clone_url"`
    OriginalURL   string `yaml:"original_url"`
    DefaultBranch string
}

Repository defines a standard repository information

type RetryDownloader Uses

type RetryDownloader struct {
    Downloader

    RetryTimes int // the total execute times
    RetryDelay int // time to delay seconds
    // contains filtered or unexported fields
}

RetryDownloader retry the downloads

func NewRetryDownloader Uses

func NewRetryDownloader(ctx context.Context, downloader Downloader, retryTimes, retryDelay int) *RetryDownloader

NewRetryDownloader creates a retry downloader

func (*RetryDownloader) GetComments Uses

func (d *RetryDownloader) GetComments(issueNumber int64) ([]*Comment, error)

GetComments returns a repository's comments with retry

func (*RetryDownloader) GetIssues Uses

func (d *RetryDownloader) GetIssues(page, perPage int) ([]*Issue, bool, error)

GetIssues returns a repository's issues with retry

func (*RetryDownloader) GetLabels Uses

func (d *RetryDownloader) GetLabels() ([]*Label, error)

GetLabels returns a repository's labels with retry

func (*RetryDownloader) GetMilestones Uses

func (d *RetryDownloader) GetMilestones() ([]*Milestone, error)

GetMilestones returns a repository's milestones with retry

func (*RetryDownloader) GetPullRequests Uses

func (d *RetryDownloader) GetPullRequests(page, perPage int) ([]*PullRequest, bool, error)

GetPullRequests returns a repository's pull requests with retry

func (*RetryDownloader) GetReleases Uses

func (d *RetryDownloader) GetReleases() ([]*Release, error)

GetReleases returns a repository's releases with retry

func (*RetryDownloader) GetRepoInfo Uses

func (d *RetryDownloader) GetRepoInfo() (*Repository, error)

GetRepoInfo returns a repository information with retry

func (*RetryDownloader) GetReviews Uses

func (d *RetryDownloader) GetReviews(pullRequestNumber int64) ([]*Review, error)

GetReviews returns pull requests reviews

func (*RetryDownloader) GetTopics Uses

func (d *RetryDownloader) GetTopics() ([]string, error)

GetTopics returns a repository's topics with retry

func (*RetryDownloader) SetContext Uses

func (d *RetryDownloader) SetContext(ctx context.Context)

SetContext set context

type Review Uses

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

type ReviewComment Uses

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 Uploader Uses

type Uploader interface {
    MaxBatchInsertSize(tp string) int
    CreateRepo(repo *Repository, opts MigrateOptions) error
    CreateTopics(topic ...string) error
    CreateMilestones(milestones ...*Milestone) error
    CreateReleases(releases ...*Release) error
    SyncTags() error
    CreateLabels(labels ...*Label) error
    CreateIssues(issues ...*Issue) error
    CreateComments(comments ...*Comment) error
    CreatePullRequests(prs ...*PullRequest) error
    CreateReviews(reviews ...*Review) error
    Rollback() error
    Finish() error
    Close()
}

Uploader uploads all the informations of one repository

Package base imports 6 packages (graph) and is imported by 14 packages. Updated 2021-01-22. Refresh now. Tools for package owners.