Help us shape the future of Go! Take the 2026 Go Developer Survey

giteahttpmigration

package
v1.17.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package giteahttpmigration migrates selected Git repositories and their account/RBAC data through HTTP only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Method     string
	URL        string
	StatusCode int
	Body       string
}

func (*APIError) Error

func (e *APIError) Error() string

type Collaborator

type Collaborator struct {
	UserName   string `json:"username"`
	Permission string `json:"permission"`
}

type ConflictPolicy

type ConflictPolicy string
const (
	ConflictFail ConflictPolicy = "fail"
	ConflictSkip ConflictPolicy = "skip"
)

type Credential

type Credential struct {
	UserName           string `json:"username"`
	TemporaryPassword  string `json:"temporary_password"`
	MustChangePassword bool   `json:"must_change_password"`
}

type CredentialWriter

type CredentialWriter interface {
	WriteCredential(Credential) error
}

type GitObject

type GitObject struct {
	Type string `json:"type"`
	SHA  string `json:"sha"`
}

type Issue added in v1.3.0

type Issue struct {
	Number    int64          `json:"number"`
	Title     string         `json:"title"`
	Body      string         `json:"body,omitempty"`
	State     string         `json:"state"`
	User      *User          `json:"user,omitempty"`
	Labels    []Label        `json:"labels,omitempty"`
	Milestone *Milestone     `json:"milestone,omitempty"`
	Assignees []User         `json:"assignees,omitempty"`
	Comments  []IssueComment `json:"comments,omitempty"`
	// PullRequest is set when a listing mixes pull requests into the issue feed.
	PullRequest *struct{} `json:"pull_request,omitempty"`
}

Issue is a non-pull issue. Numbers are recreated in order on an empty tracker.

type IssueComment added in v1.3.0

type IssueComment struct {
	Body string `json:"body"`
	User *User  `json:"user,omitempty"`
}

IssueComment is a human comment. Review threads and attachments are not copied.

type JSONLCredentialFile

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

func NewJSONLCredentialFile

func NewJSONLCredentialFile(filePath string) (*JSONLCredentialFile, error)

func (*JSONLCredentialFile) Close

func (f *JSONLCredentialFile) Close() error

func (*JSONLCredentialFile) WriteCredential

func (f *JSONLCredentialFile) WriteCredential(credential Credential) error

type Label added in v1.3.0

type Label struct {
	ID          int64  `json:"id,omitempty"`
	Name        string `json:"name"`
	Color       string `json:"color"`
	Description string `json:"description,omitempty"`
	Exclusive   bool   `json:"exclusive,omitempty"`
}

Label is a repository label copied by name. Target IDs are assigned on create.

type Migrator

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

func New

func New(options Options) (*Migrator, error)

func (*Migrator) Apply

func (m *Migrator) Apply(ctx context.Context, plan *Plan, credentials CredentialWriter) (*Result, error)

func (*Migrator) Discover

func (m *Migrator) Discover(ctx context.Context) (*Plan, error)

func (*Migrator) SyncGitRepositories added in v1.3.0

func (m *Migrator) SyncGitRepositories(ctx context.Context, plan *Plan) (*Result, error)

SyncGitRepositories updates Git refs and LFS objects on repositories that already exist on the target. The persistent local bare cache keeps subsequent source fetches incremental.

type Milestone added in v1.3.0

type Milestone struct {
	ID          int64      `json:"id,omitempty"`
	Title       string     `json:"title"`
	Description string     `json:"description,omitempty"`
	State       string     `json:"state"`
	DueOn       *time.Time `json:"due_on,omitempty"`
}

Milestone is a repository milestone copied by title.

type MirrorRequest

type MirrorRequest struct {
	SourceURL      string
	SourceLogin    string
	SourceToken    string
	TargetURL      string
	TargetLogin    string
	TargetToken    string
	CacheDir       string
	UpdateExisting bool
}

type Options

type Options struct {
	SourceURL       string
	SourceUser      string
	SourcePassword  string
	SourceToken     string
	TargetURL       string
	TargetUser      string
	TargetPassword  string
	TargetToken     string
	Repositories    []string
	AllRepositories bool
	ConflictPolicy  ConflictPolicy
	HTTPClient      *http.Client
	Mirror          RepositoryMirror
	MirrorCacheDir  string
	SyncExistingGit bool
}

type Organization

type Organization struct {
	Name                      string `json:"name"`
	FullName                  string `json:"full_name"`
	Email                     string `json:"email"`
	Description               string `json:"description"`
	Website                   string `json:"website"`
	Location                  string `json:"location"`
	Visibility                string `json:"visibility"`
	RepoAdminChangeTeamAccess bool   `json:"repo_admin_change_team_access"`
}

type OrganizationPlan

type OrganizationPlan struct {
	Organization  Organization `json:"organization"`
	Owner         string       `json:"owner"`
	PublicMembers []string     `json:"public_members,omitempty"`
	Teams         []TeamPlan   `json:"teams"`
}

type PackageCopy added in v1.3.0

type PackageCopy struct {
	Type       string        `json:"type"`
	Name       string        `json:"name"`
	Version    string        `json:"version"`
	Repository *Repository   `json:"repository,omitempty"`
	Files      []PackageFile `json:"files,omitempty"`
}

PackageCopy is a package version linked to the repository. Only generic packages are copied byte for byte. Other package types use their own upload protocols and are reported, not re-encoded.

type PackageFile added in v1.3.0

type PackageFile struct {
	Name         string `json:"name"`
	Size         int64  `json:"size"`
	SHA256       string `json:"sha256,omitempty"`
	CompositeKey string `json:"composite_key,omitempty"`
}

PackageFile is one file inside a package version.

type Plan

type Plan struct {
	SourceURL     string             `json:"source_url"`
	SourceLogin   string             `json:"source_login"`
	TargetURL     string             `json:"target_url"`
	Users         []User             `json:"users"`
	Organizations []OrganizationPlan `json:"organizations"`
	Repositories  []RepositoryPlan   `json:"repositories"`
	GitOnlySync   bool               `json:"git_only_sync,omitempty"`
	Warnings      []string           `json:"warnings,omitempty"`
}

type PullRef added in v1.3.0

type PullRef struct {
	Ref  string      `json:"ref"`
	SHA  string      `json:"sha,omitempty"`
	Repo *Repository `json:"repo,omitempty"`
}

PullRef is the head or base of a pull request.

type PullRequest added in v1.3.0

type PullRequest struct {
	Number    int64          `json:"number"`
	Title     string         `json:"title"`
	Body      string         `json:"body,omitempty"`
	State     string         `json:"state"`
	Merged    bool           `json:"merged,omitempty"`
	User      *User          `json:"user,omitempty"`
	Head      *PullRef       `json:"head"`
	Base      *PullRef       `json:"base"`
	Labels    []Label        `json:"labels,omitempty"`
	Milestone *Milestone     `json:"milestone,omitempty"`
	Assignees []User         `json:"assignees,omitempty"`
	Comments  []IssueComment `json:"comments,omitempty"`
	Reviews   []PullReview   `json:"reviews,omitempty"`
}

PullRequest is recreated against branches that the Git mirror already pushed. Merged requests are closed on the target; the merge commit itself is not replayed.

type PullReview added in v1.3.0

type PullReview struct {
	ID       int64           `json:"id,omitempty"`
	Body     string          `json:"body,omitempty"`
	State    string          `json:"state,omitempty"`
	CommitID string          `json:"commit_id,omitempty"`
	User     *User           `json:"user,omitempty"`
	Comments []ReviewComment `json:"comments,omitempty"`
}

PullReview is one submitted review. Pending reviews are imported as comments.

type Reference

type Reference struct {
	Ref    string     `json:"ref"`
	Object *GitObject `json:"object"`
}

type Release added in v1.3.0

type Release struct {
	ID         int64          `json:"id,omitempty"`
	TagName    string         `json:"tag_name"`
	Name       string         `json:"name,omitempty"`
	Body       string         `json:"body,omitempty"`
	Draft      bool           `json:"draft,omitempty"`
	Prerelease bool           `json:"prerelease,omitempty"`
	Target     string         `json:"target_commitish,omitempty"`
	Assets     []ReleaseAsset `json:"assets,omitempty"`
}

Release is release metadata. Attachment bytes are downloaded during apply.

type ReleaseAsset added in v1.3.0

type ReleaseAsset struct {
	ID          int64  `json:"id,omitempty"`
	Name        string `json:"name"`
	Size        int64  `json:"size"`
	DownloadURL string `json:"browser_download_url"`
}

ReleaseAsset is a release file. Bytes are fetched from DownloadURL during apply.

type Repository

type Repository struct {
	Owner           *User  `json:"owner"`
	Name            string `json:"name"`
	FullName        string `json:"full_name"`
	Description     string `json:"description"`
	Private         bool   `json:"private"`
	Internal        bool   `json:"internal"`
	Empty           bool   `json:"empty"`
	CloneURL        string `json:"clone_url"`
	DefaultBranch   string `json:"default_branch"`
	Archived        bool   `json:"archived"`
	HasIssues       *bool  `json:"has_issues,omitempty"`
	HasPullRequests *bool  `json:"has_pull_requests,omitempty"`
	HasReleases     *bool  `json:"has_releases,omitempty"`
	HasWiki         *bool  `json:"has_wiki,omitempty"`
	HasActions      *bool  `json:"has_actions,omitempty"`
}

type RepositoryMirror

type RepositoryMirror func(context.Context, MirrorRequest) error

type RepositoryPlan

type RepositoryPlan struct {
	Repository         Repository     `json:"repository"`
	Refs               []Reference    `json:"refs,omitempty"`
	Collaborators      []Collaborator `json:"collaborators,omitempty"`
	OwnerCollaborators []string       `json:"owner_collaborators,omitempty"`
	Labels             []Label        `json:"labels,omitempty"`
	Milestones         []Milestone    `json:"milestones,omitempty"`
	Issues             []Issue        `json:"issues,omitempty"`
	Pulls              []PullRequest  `json:"pulls,omitempty"`
	Releases           []Release      `json:"releases,omitempty"`
	Wiki               []WikiPage     `json:"wiki,omitempty"`
	Packages           []PackageCopy  `json:"packages,omitempty"`
}

type RepositoryRef

type RepositoryRef struct {
	Owner string `json:"owner"`
	Name  string `json:"name"`
}

func (RepositoryRef) String

func (r RepositoryRef) String() string

type Result

type Result struct {
	UsersCreated          int      `json:"users_created"`
	UsersSkipped          int      `json:"users_skipped"`
	OrganizationsCreated  int      `json:"organizations_created"`
	OrganizationsSkipped  int      `json:"organizations_skipped"`
	TeamsCreated          int      `json:"teams_created"`
	TeamsReused           int      `json:"teams_reused"`
	RepositoriesCreated   int      `json:"repositories_created"`
	RepositoriesSkipped   int      `json:"repositories_skipped"`
	GitRepositoriesSynced int      `json:"git_repositories_synced"`
	TeamMemberships       int      `json:"team_memberships_applied"`
	TeamRepositories      int      `json:"team_repositories_applied"`
	Collaborators         int      `json:"collaborators_applied"`
	PublicMemberships     int      `json:"public_memberships_applied"`
	RefsVerified          int      `json:"refs_verified"`
	LabelsCreated         int      `json:"labels_created"`
	MilestonesCreated     int      `json:"milestones_created"`
	IssuesCreated         int      `json:"issues_created"`
	PullsCreated          int      `json:"pulls_created"`
	CommentsCreated       int      `json:"comments_created"`
	ReleasesCreated       int      `json:"releases_created"`
	AssetsCreated         int      `json:"assets_created"`
	WikiPagesCreated      int      `json:"wiki_pages_created"`
	ReviewsCreated        int      `json:"reviews_created"`
	PackagesCopied        int      `json:"packages_copied"`
	PackagesSkipped       int      `json:"packages_skipped"`
	ContentSkipped        int      `json:"content_skipped"`
	IndexRemaps           int      `json:"index_remaps"`
	Notes                 []string `json:"notes,omitempty"`
}

type ReviewComment added in v1.3.0

type ReviewComment struct {
	ID       int64  `json:"id,omitempty"`
	Body     string `json:"body"`
	Path     string `json:"path,omitempty"`
	LineNum  uint64 `json:"position,omitempty"`
	User     *User  `json:"user,omitempty"`
	Resolver *User  `json:"resolver,omitempty"`
}

ReviewComment is a line comment on a review. Resolver is set when the source comment was marked resolved.

type Team

type Team struct {
	ID                      int64             `json:"id"`
	Name                    string            `json:"name"`
	DisplayName             string            `json:"display_name,omitempty"`
	Visibility              string            `json:"visibility,omitempty"`
	Description             string            `json:"description"`
	IncludesAllRepositories bool              `json:"includes_all_repositories"`
	Permission              string            `json:"permission"`
	Units                   []string          `json:"units,omitempty"`
	UnitsMap                map[string]string `json:"units_map,omitempty"`
	CanCreateOrgRepo        bool              `json:"can_create_org_repo"`
}

type TeamPlan

type TeamPlan struct {
	Team         Team            `json:"team"`
	Members      []string        `json:"members"`
	Repositories []RepositoryRef `json:"repositories"`
}

type User

type User struct {
	UserName      string    `json:"login"`
	FullName      string    `json:"full_name"`
	Email         string    `json:"email"`
	Visibility    string    `json:"visibility"`
	Restricted    bool      `json:"restricted"`
	IsAdmin       bool      `json:"is_admin"`
	IsActive      bool      `json:"active"`
	ProhibitLogin bool      `json:"prohibit_login"`
	Created       time.Time `json:"created"`
}

type WikiPage added in v1.3.0

type WikiPage struct {
	Title         string `json:"title"`
	ContentBase64 string `json:"content_base64,omitempty"`
}

WikiPage is one wiki page. ContentBase64 is the Gitea wiki payload.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL