aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorHaruo Kinoshita <haruo31@underthetree.jp>2023-01-17 16:22:00 +0900
committerGitHub <noreply@github.com>2023-01-17 15:22:00 +0800
commit9edf80f472e9307d89cab1c22e7c0c185a50deb7 (patch)
tree2af6affd7dbd28b2b023042da3e78b5b4d6cce70 /services
parent3510d7e33ace5302691b6e96b9bde71148ed6e4c (diff)
downloadgitea-9edf80f472e9307d89cab1c22e7c0c185a50deb7.tar.gz
gitea-9edf80f472e9307d89cab1c22e7c0c185a50deb7.zip
Fix migration from gitbucket (repost) (#22477)
Reposting pull request for #22465 > Migration from GitBucket does not work due to a access for "Reviews" API on GitBucket that makes 404 response. This PR has following changes. > 1. Made to stop access for Reviews API while migrating from GitBucket. > 2. Added support for custom URL (e.g. `http://example.com/gitbucket/owner/repository`) > 3. Made to accept for git checkout URL (`http://example.com/git/owner/repository.git`) Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'services')
-rw-r--r--services/migrations/gitbucket.go11
-rw-r--r--services/migrations/github.go4
2 files changed, 12 insertions, 3 deletions
diff --git a/services/migrations/gitbucket.go b/services/migrations/gitbucket.go
index 65c138ed04..cc3d4fc936 100644
--- a/services/migrations/gitbucket.go
+++ b/services/migrations/gitbucket.go
@@ -33,10 +33,14 @@ func (f *GitBucketDownloaderFactory) New(ctx context.Context, opts base.MigrateO
return nil, err
}
- baseURL := u.Scheme + "://" + u.Host
fields := strings.Split(u.Path, "/")
- oldOwner := fields[1]
- oldName := strings.TrimSuffix(fields[2], ".git")
+ if len(fields) < 2 {
+ return nil, fmt.Errorf("invalid path: %s", u.Path)
+ }
+ baseURL := u.Scheme + "://" + u.Host + strings.TrimSuffix(strings.Join(fields[:len(fields)-2], "/"), "/git")
+
+ oldOwner := fields[len(fields)-2]
+ oldName := strings.TrimSuffix(fields[len(fields)-1], ".git")
log.Trace("Create GitBucket downloader. BaseURL: %s RepoOwner: %s RepoName: %s", baseURL, oldOwner, oldName)
return NewGitBucketDownloader(ctx, baseURL, opts.AuthUsername, opts.AuthPassword, opts.AuthToken, oldOwner, oldName), nil
@@ -71,6 +75,7 @@ func (g *GitBucketDownloader) ColorFormat(s fmt.State) {
func NewGitBucketDownloader(ctx context.Context, baseURL, userName, password, token, repoOwner, repoName string) *GitBucketDownloader {
githubDownloader := NewGithubDownloaderV3(ctx, baseURL, userName, password, token, repoOwner, repoName)
githubDownloader.SkipReactions = true
+ githubDownloader.SkipReviews = true
return &GitBucketDownloader{
githubDownloader,
}
diff --git a/services/migrations/github.go b/services/migrations/github.go
index 48dd90323d..d34ad13b95 100644
--- a/services/migrations/github.go
+++ b/services/migrations/github.go
@@ -76,6 +76,7 @@ type GithubDownloaderV3 struct {
curClientIdx int
maxPerPage int
SkipReactions bool
+ SkipReviews bool
}
// NewGithubDownloaderV3 creates a github Downloader via github v3 API
@@ -809,6 +810,9 @@ func (g *GithubDownloaderV3) convertGithubReviewComments(cs []*github.PullReques
// GetReviews returns pull requests review
func (g *GithubDownloaderV3) GetReviews(reviewable base.Reviewable) ([]*base.Review, error) {
allReviews := make([]*base.Review, 0, g.maxPerPage)
+ if g.SkipReviews {
+ return allReviews, nil
+ }
opt := &github.ListOptions{
PerPage: g.maxPerPage,
}