mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-26 06:16:56 +09:00
feat(migrations): add migration from Bitbucket Server (Data Center) (#39913)
Add migration from Bitbucket Server (Data Center). It has no issues, wiki, milestones or releases, so those are not offered. Migrated: git data with tags and LFS, and pull requests with state, draft flag, merge commit/base, comments, approvals and inline code comments including resolved threads. Multi-line ranges become a `Lines a-b:` text prefix, as Gitea anchors code comments to one line. Auth is an HTTP access token (personal, project or repository) or username/password; 429 responses are retried. Changes outside the downloader: - `ReviewComment.Resolved`, applied by the uploader. - The uploader creates a fork PR's head branch from its head commit when already in the repository, instead of fetching the fork (Bitbucket keeps it in `refs/pull-requests/<id>/from`; private forks need credentials). Tested with unit tests, responses recorded from Bitbucket 10.5.1, and an end-to-end migration. Independent of https://github.com/go-gitea/gitea/pull/38607 (Bitbucket Cloud); the service type enum value needs adjusting for whichever lands second. --------- Co-authored-by: bircni <bircni@icloud.com>
This commit is contained in:
1 parent
8cd7721deb
commit
a2da5cd7b5
25 files changed
+1575
-45
No files matched your search
@@ -62,6 +62,7 @@ type ReviewComment struct {
|
||||
Line int
|
||||
CommitID string `yaml:"commit_id"`
|
||||
PosterID int64 `yaml:"poster_id"`
|
||||
Resolved bool // the conversation of this (first) comment is resolved
|
||||
Reactions []*Reaction
|
||||
CreatedAt time.Time `yaml:"created_at"`
|
||||
UpdatedAt time.Time `yaml:"updated_at"`
|
||||
|
||||
+34
-12
@@ -347,22 +347,23 @@ type GitServiceType int
|
||||
|
||||
// enumerate all GitServiceType
|
||||
const (
|
||||
NotMigrated GitServiceType = iota // 0 not migrated from external sites
|
||||
PlainGitService // 1 plain git service
|
||||
GithubService // 2 github.com
|
||||
GiteaService // 3 gitea service
|
||||
GitlabService // 4 gitlab service
|
||||
GogsService // 5 gogs service
|
||||
OneDevService // 6 onedev service
|
||||
GitBucketService // 7 gitbucket service
|
||||
CodebaseService // 8 codebase service
|
||||
CodeCommitService // 9 codecommit service
|
||||
NotMigrated GitServiceType = iota // 0 not migrated from external sites
|
||||
PlainGitService // 1 plain git service
|
||||
GithubService // 2 github.com
|
||||
GiteaService // 3 gitea service
|
||||
GitlabService // 4 gitlab service
|
||||
GogsService // 5 gogs service
|
||||
OneDevService // 6 onedev service
|
||||
GitBucketService // 7 gitbucket service
|
||||
CodebaseService // 8 codebase service
|
||||
CodeCommitService // 9 codecommit service
|
||||
BitbucketServerService // 10 bitbucket server (data center) service
|
||||
)
|
||||
|
||||
// Name represents the service type's name
|
||||
// WARNING: the name has to be equal to that on goth's library
|
||||
func (gt GitServiceType) Name() string {
|
||||
return strings.ToLower(gt.Title())
|
||||
return strings.ToLower(strings.ReplaceAll(gt.Title(), " ", ""))
|
||||
}
|
||||
|
||||
// Title represents the service type's proper title
|
||||
@@ -384,12 +385,32 @@ func (gt GitServiceType) Title() string {
|
||||
return "Codebase"
|
||||
case CodeCommitService:
|
||||
return "CodeCommit"
|
||||
case BitbucketServerService:
|
||||
return "Bitbucket Server"
|
||||
case PlainGitService:
|
||||
return "Git"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Variants returns the hosting options of gt's provider, which share one entry on the migrate page
|
||||
func (gt GitServiceType) Variants() []GitServiceType {
|
||||
switch gt {
|
||||
case BitbucketServerService:
|
||||
return []GitServiceType{BitbucketServerService}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ProviderTitle returns the title of gt's entry on the migrate page
|
||||
func (gt GitServiceType) ProviderTitle() string {
|
||||
switch gt {
|
||||
case BitbucketServerService:
|
||||
return "Bitbucket"
|
||||
}
|
||||
return gt.Title()
|
||||
}
|
||||
|
||||
// MigrateRepoOptions options for migrating repository's
|
||||
// this is used to interact with api v1
|
||||
type MigrateRepoOptions struct {
|
||||
@@ -402,7 +423,7 @@ type MigrateRepoOptions struct {
|
||||
// required: true
|
||||
RepoName string `json:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"`
|
||||
|
||||
// enum: ["git","github","gitea","gitlab","gogs","onedev","gitbucket","codebase","codecommit"]
|
||||
// enum: ["git","github","gitea","gitlab","gogs","onedev","gitbucket","codebase","codecommit","bitbucketserver"]
|
||||
Service string `json:"service"`
|
||||
AuthUsername string `json:"auth_username"`
|
||||
AuthPassword string `json:"auth_password"`
|
||||
@@ -445,6 +466,7 @@ var SupportedFullGitService = []GitServiceType{
|
||||
GitBucketService,
|
||||
CodebaseService,
|
||||
CodeCommitService,
|
||||
BitbucketServerService,
|
||||
}
|
||||
|
||||
// RepoTransfer represents a pending repo transfer
|
||||
|
||||
Reference in new issue
Block a user