feat(migrations): add repository migration from bitbucket.org - #38607
feat(migrations): add repository migration from bitbucket.org#38607lunny wants to merge 2 commits into
Conversation
|
+1.294 for a new migration source seems quite bad, we should probably rewrite and dedupe a lot of this migration code eventually. |
|
Yeah, maybe later, but I guess we should take this now as-is. |
Take this copied&pasted code as-is? Oh no ...... |
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestBitbucketDownloadRepo(t *testing.T) { |
There was a problem hiding this comment.
I take it this has no reference repo on bitbucket to test against and that is why the reply capturing and replaying framework @silverwind made isn't used here?
There was a problem hiding this comment.
Could make a temp reference repo on bitbucket.org and capture for the migration tests, highly recommended.
There was a problem hiding this comment.
But buibucket.org has a rate limit which is very slow.
There was a problem hiding this comment.
I assume you need a API token to get around public rate limits, this is the same already for the GitLab capture.
| workspace := fields[0] | ||
| repoSlug := strings.TrimSuffix(fields[1], ".git") | ||
| webBaseURL := u.Scheme + "://" + u.Host | ||
| apiBaseURL := "https://api.bitbucket.org/2.0" |
There was a problem hiding this comment.
hardcoded despite the web url being taken from url? What about self-hosted instances?
There was a problem hiding this comment.
As I know, bitbucket server has a different API from the cloud.
There was a problem hiding this comment.
For those who are using bitbucket server, https://github.com/appleboy/BitbucketServer2Gitea is a better choice.
There was a problem hiding this comment.
If so why is webBaseURL being made from the request? I wouldn't expect host to be anything but https://bitbucket.org ?

What this PR does
Adds support for migrating repositories and their metadata from bitbucket.org (Bitbucket Cloud), following Gitea's existing migration framework. Both the web UI and the REST API (
POST /repos/migratewithservice=bitbucket) are supported.Migrated content
Implemented via the Bitbucket Cloud REST API v2:
kind/*,priority/*,component/*,version/*)Bitbucket has no "release" concept, so releases are not supported and the option is hidden in the migration UI. Bitbucket also uses separate numbering for issues and pull requests, so PR numbers are offset past the highest issue ID to avoid index collisions.
Rate limiting
Bitbucket Cloud enforces per-hour rate limits and returns HTTP 429 with an
X-RateLimit-Resetheader expressed as seconds-remaining (not a Unix epoch) and noRetry-After. The downloader transparently waits-and-retries on 429 (and transient 5xx) for idempotent GET requests:Retry-After, thenX-RateLimit-Reset(delta-seconds, with epoch/RFC3339 fallbacks), then exponential backoff with jittercontextAuth / clone
Supports username + app password (basic auth) and access tokens.
FormatCloneURLuses Bitbucket's requiredx-token-authusername when cloning with a token.UI
bitbucket.tmpl); Bitbucket appears after Gitea and before Gogs.minmax(200px, 1fr)) with smaller icons, and fixed a long-standing bug where the card divider followed the text width instead of spanning the full card.Tests
Retry-After, delta reset, epoch, RFC3339, backoff)TestToGitServiceTypeextended forbitbucketTestRepoMigrationUIintegration test verifying the migration forms renderNotes
serviceenum now includesbitbucket).en-USlocale was updated; other locales go through Crowdin.ScreenShot