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:
Lunny Xiaoandbircni authored and GitHub committed 2026-10-23 19:25:29 +00:00
1 parent 8cd7721deb
commit a2da5cd7b5
25 files changed
+1575 -45

No files matched your search

@@ -0,0 +1,54 @@
{{template "base/head" .}}
<div role="main" aria-label="{{.Title}}" class="page-content repository new migrate">
<div class="ui container medium-width">
<h3 class="ui top attached header">
{{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}}
</h3>
<div class="ui attached segment">
{{template "base/alert" .}}
<form class="ui form left-right-form form-fetch-action" action="{{.Link}}" method="post">
{{template "repo/migrate/common-init" (dict "ServiceType" .service)}}
{{template "repo/migrate/variants" .}}
<div class="inline required field">
<label>{{ctx.Locale.Tr "repo.migrate.clone_address"}}</label>
<input name="clone_addr" autofocus required>
<span class="help">
{{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}}
</span>
</div>
<div class="inline field">
<label>{{ctx.Locale.Tr "username"}}</label>
<input name="auth_username">
</div>
<div class="inline field">
<label>{{ctx.Locale.Tr "password"}}</label>
<input name="auth_password" type="password">
</div>
<div class="inline field">
<label>{{ctx.Locale.Tr "access_token"}}</label>
<input name="auth_token" type="password" autocomplete="new-password">
<span class="help">{{ctx.Locale.Tr "repo.migrate.bitbucketserver.token_desc"}}</span>
</div>
{{template "repo/migrate/common-options" .}}
<div id="migrate_items">
<div class="inline field">
<label>{{ctx.Locale.Tr "repo.migrate_items"}}</label>
<div class="ui checkbox">
<input name="pull_requests" type="checkbox">
<label>{{ctx.Locale.Tr "repo.migrate_items_pullrequests"}}</label>
</div>
</div>
</div>
<div class="divider"></div>
{{template "repo/migrate/common-migrated-repo"}}
</form>
</div>
</div>
</div>
{{template "base/footer" .}}
+3 -1
View File
@@ -10,6 +10,8 @@
{{svg "octicon-mark-github" 184 "tw-p-4"}}
{{else if eq .Name "gitlab"}}
{{svg "gitea-gitlab" 184 "tw-p-4"}}
{{else if eq .Name "bitbucketserver"}}
{{svg "gitea-bitbucket" 184 "tw-p-4"}}
{{else if eq .Name "gitbucket"}}
{{svg "gitea-gitbucket" 184 "tw-p-4"}}
{{else}}
@@ -17,7 +19,7 @@
{{end}}
<div class="content">
<div class="header tw-text-center">
{{.Title}}
{{.ProviderTitle}}
</div>
<div class="description tw-text-center tw-text-balance">
{{ctx.Locale.Tr (printf "repo.migrate.%s.description" .Name)}}
+10
View File
@@ -0,0 +1,10 @@
{{if gt (len .ServiceVariants) 1}}
<div class="inline field">
<label>{{ctx.Locale.Tr "repo.migrate.hosting"}}</label>
<div class="ui compact small menu">
{{range .ServiceVariants}}
<a class="item {{Iif (eq . $.service) "active"}}" href="{{AppSubUrl}}/repo/migrate?service_type={{.}}&org={{$.ContextUser.ID}}&mirror={{$.mirror}}">{{ctx.Locale.Tr (printf "repo.migrate.%s.variant" .Name)}}</a>
{{end}}
</div>
</div>
{{end}}
+2 -1
View File
@@ -7988,7 +7988,8 @@
"onedev",
"gitbucket",
"codebase",
"codecommit"
"codecommit",
"bitbucketserver"
],
"type": "string",
"x-go-name": "Service"
+2 -1
View File
@@ -31829,7 +31829,8 @@
"onedev",
"gitbucket",
"codebase",
"codecommit"
"codecommit",
"bitbucketserver"
],
"x-go-name": "Service"
},