"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "vendor/code.gitea.io/sdk/gitea/repo_migrate.go" between
gitea-1.13.1.tar.gz and gitea-1.13.2.tar.gz

About: Gitea allows to set up a self-hosted code hosting Git service (a fork of Gogs).

repo_migrate.go  (gitea-1.13.1):repo_migrate.go  (gitea-1.13.2)
skipping to change at line 23 skipping to change at line 23
// GitServiceType represents a git service // GitServiceType represents a git service
type GitServiceType string type GitServiceType string
const ( const (
// GitServicePlain represents a plain git service // GitServicePlain represents a plain git service
GitServicePlain GitServiceType = "git" GitServicePlain GitServiceType = "git"
//GitServiceGithub represents github.com //GitServiceGithub represents github.com
GitServiceGithub GitServiceType = "github" GitServiceGithub GitServiceType = "github"
// GitServiceGitlab represents a gitlab service // GitServiceGitlab represents a gitlab service
GitServiceGitlab GitServiceType = "gitlab" GitServiceGitlab GitServiceType = "gitlab"
// GitServiceGitea represents a gitea service
GitServiceGitea GitServiceType = "gitea"
// Not supported jet // Not supported jet
// // GitServiceGitea represents a gitea service
// GitServiceGitea GitServiceType = "gitea"
// // GitServiceGogs represents a gogs service // // GitServiceGogs represents a gogs service
// GitServiceGogs GitServiceType = "gogs" // GitServiceGogs GitServiceType = "gogs"
) )
// MigrateRepoOption options for migrating a repository from an external service // MigrateRepoOption options for migrating a repository from an external service
type MigrateRepoOption struct { type MigrateRepoOption struct {
RepoName string `json:"repo_name"` RepoName string `json:"repo_name"`
RepoOwner string `json:"repo_owner"` RepoOwner string `json:"repo_owner"`
// deprecated use RepoOwner // deprecated use RepoOwner
RepoOwnerID int64 `json:"uid"` RepoOwnerID int64 `json:"uid"`
skipping to change at line 54 skipping to change at line 54
Description string `json:"description"` Description string `json:"description"`
Wiki bool `json:"wiki"` Wiki bool `json:"wiki"`
Milestones bool `json:"milestones"` Milestones bool `json:"milestones"`
Labels bool `json:"labels"` Labels bool `json:"labels"`
Issues bool `json:"issues"` Issues bool `json:"issues"`
PullRequests bool `json:"pull_requests"` PullRequests bool `json:"pull_requests"`
Releases bool `json:"releases"` Releases bool `json:"releases"`
} }
// Validate the MigrateRepoOption struct // Validate the MigrateRepoOption struct
func (opt *MigrateRepoOption) Validate() error { func (opt *MigrateRepoOption) Validate(c *Client) error {
// check user options // check user options
if len(opt.CloneAddr) == 0 { if len(opt.CloneAddr) == 0 {
return fmt.Errorf("CloneAddr required") return fmt.Errorf("CloneAddr required")
} }
if len(opt.RepoName) == 0 { if len(opt.RepoName) == 0 {
return fmt.Errorf("RepoName required") return fmt.Errorf("RepoName required")
} else if len(opt.RepoName) > 100 { } else if len(opt.RepoName) > 100 {
return fmt.Errorf("RepoName to long") return fmt.Errorf("RepoName to long")
} }
if len(opt.Description) > 255 { if len(opt.Description) > 255 {
return fmt.Errorf("Description to long") return fmt.Errorf("Description to long")
} }
switch opt.Service { switch opt.Service {
case GitServiceGithub: case GitServiceGithub:
if len(opt.AuthToken) == 0 { if len(opt.AuthToken) == 0 {
return fmt.Errorf("github require token authentication") return fmt.Errorf("github require token authentication")
} }
case GitServiceGitlab, GitServiceGitea:
if len(opt.AuthToken) == 0 {
return fmt.Errorf("%s require token authentication", opt.
Service)
}
// Gitlab is supported since 1.12.0 but api cant handle it until
1.13.0
// https://github.com/go-gitea/gitea/pull/12672
if c.checkServerVersionGreaterThanOrEqual(version1_13_0) != nil {
return fmt.Errorf("migrate from service %s need gitea >=
1.13.0", opt.Service)
}
} }
return nil return nil
} }
// MigrateRepo migrates a repository from other Git hosting sources for the auth enticated user. // MigrateRepo migrates a repository from other Git hosting sources for the auth enticated user.
// //
// To migrate a repository for a organization, the authenticated user must be a // To migrate a repository for a organization, the authenticated user must be a
// owner of the specified organization. // owner of the specified organization.
func (c *Client) MigrateRepo(opt MigrateRepoOption) (*Repository, *Response, err or) { func (c *Client) MigrateRepo(opt MigrateRepoOption) (*Repository, *Response, err or) {
if err := opt.Validate(); err != nil { if err := opt.Validate(c); err != nil {
return nil, nil, err return nil, nil, err
} }
if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil { if err := c.checkServerVersionGreaterThanOrEqual(version1_13_0); err != n il {
if len(opt.AuthToken) != 0 { if len(opt.AuthToken) != 0 {
// gitea <= 1.12 dont understand AuthToken // gitea <= 1.12 dont understand AuthToken
opt.AuthUsername = opt.AuthToken opt.AuthUsername = opt.AuthToken
opt.AuthPassword, opt.AuthToken = "", "" opt.AuthPassword, opt.AuthToken = "", ""
} }
if len(opt.RepoOwner) != 0 { if len(opt.RepoOwner) != 0 {
// gitea <= 1.12 dont understand RepoOwner // gitea <= 1.12 dont understand RepoOwner
u, _, err := c.GetUserInfo(opt.RepoOwner) u, _, err := c.GetUserInfo(opt.RepoOwner)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
 End of changes. 6 change blocks. 
5 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)