-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to migrate from gogs #14342
Merged
Merged
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
5f3196f
add support to migrate from gogs
lunny 21533a4
remove test since it depends on try.gogs.io
lunny 78d75c5
handle unsupported error
lunny 7417afd
fix vendor
lunny efcf78d
fix go.sum
lunny 9fe0b4a
ignore gogs test since it depends on try.gogs.io
lunny 64b371a
Merge branch 'master' into lunny/downloader_gogs
6543 93a97ad
adapt: 'migrate service type switch page'
6543 e34e6c2
refactor & fix & update
6543 2da5710
fix
6543 2b890ff
optimize svg
6543 dc5e3ba
refactor IsErrNotSupported
6543 f509a1d
gogs dont support oauth2
6543 0dda8a9
Update modules/migrations/migrate.go
6543 8845c23
Merge branch 'master' into lunny/downloader_gogs
6543 9225b0b
fix lint
6543 f8635eb
refactor migrations downloader interface implementation(s)
6543 7518582
fix lint
6543 bb6512e
Merge branch 'master' into lunny/downloader_gogs
6543 bce51d1
handle ErrNotSupported on all downloader functions ...
6543 cf30f4f
more specific error messages
6543 07d3691
RetryDownloader: dont retry if not supported
6543 41be205
Merge branch 'master' into lunny/downloader_gogs
6543 5d7dc8d
Merge branch 'master' into lunny/downloader_gogs
6543 f8159e7
Merge branch 'master' into lunny/downloader_gogs
6543 4bbb5e2
Merge branch 'master' into lunny/downloader_gogs
6543 98fa152
fix generate CloneURL
6543 53f40f9
gogs: migrate closed issues too
6543 67f9344
optimize
6543 9a3e37d
sdk bug detected :/
6543 d70c62e
resolve TODO
6543 15f3307
fix out of slice issue
6543 aa6b837
Merge branch 'master' into lunny/downloader_gogs
6543 4099e17
fix pagination
6543 b6559cf
Merge branch 'master' into lunny/downloader_gogs
6543 08b9e41
Resolve GetTopics() TODO
6543 c177145
Merge branch 'master' into lunny/downloader_gogs
6543 72bd6de
impruve more
6543 df0e55a
Merge branch 'master' into lunny/downloader_gogs
6543 7ecc980
Merge branch 'master' into lunny/downloader_gogs
6543 f033f5e
Merge branch 'master' into lunny/downloader_gogs
6543 16dc498
nits
6543 6cd3cde
Merge branch 'master' into lunny/downloader_gogs
6543 802b532
fix get Comments
6543 c024e5d
Merge branch 'master' into lunny/downloader_gogs
6543 b6761e6
Merge branch 'master' into lunny/downloader_gogs
6543 270cabf
Merge branch 'master' into lunny/downloader_gogs
6543 1ecb88c
Merge branch 'master' into lunny/downloader_gogs
6543 5a5134d
Merge branch 'master' into lunny/downloader_gogs
6543 9b7ff34
Merge branch 'master' into lunny/downloader_gogs
6543 f1cbea2
Merge branch 'master' into lunny/downloader_gogs
6543 e6e7752
Merge branch 'master' into lunny/downloader_gogs
6543 e9109dd
Retrofit context cancellation
zeripath 19e2ed8
Update modules/migrations/gogs.go
zeripath File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2021 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package base | ||
|
||
import "fmt" | ||
|
||
// ErrNotSupported represents status if a downloader do not supported something. | ||
type ErrNotSupported struct { | ||
Entity string | ||
} | ||
|
||
// IsErrNotSupported checks if an error is an ErrNotSupported | ||
func IsErrNotSupported(err error) bool { | ||
_, ok := err.(ErrNotSupported) | ||
return ok | ||
} | ||
|
||
// Error return error message | ||
func (err ErrNotSupported) Error() string { | ||
if len(err.Entity) != 0 { | ||
return fmt.Sprintf("'%s' not supported", err.Entity) | ||
} | ||
return "not supported" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright 2021 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package base | ||
|
||
import ( | ||
"context" | ||
"net/url" | ||
) | ||
|
||
// NullDownloader implements a blank downloader | ||
type NullDownloader struct { | ||
} | ||
|
||
var ( | ||
_ Downloader = &NullDownloader{} | ||
) | ||
|
||
// SetContext set context | ||
func (n NullDownloader) SetContext(_ context.Context) {} | ||
|
||
// GetRepoInfo returns a repository information | ||
func (n NullDownloader) GetRepoInfo() (*Repository, error) { | ||
return nil, &ErrNotSupported{Entity: "RepoInfo"} | ||
} | ||
|
||
// GetTopics return repository topics | ||
func (n NullDownloader) GetTopics() ([]string, error) { | ||
return nil, &ErrNotSupported{Entity: "Topics"} | ||
} | ||
|
||
// GetMilestones returns milestones | ||
func (n NullDownloader) GetMilestones() ([]*Milestone, error) { | ||
return nil, &ErrNotSupported{Entity: "Milestones"} | ||
} | ||
|
||
// GetReleases returns releases | ||
func (n NullDownloader) GetReleases() ([]*Release, error) { | ||
return nil, &ErrNotSupported{Entity: "Releases"} | ||
} | ||
|
||
// GetLabels returns labels | ||
func (n NullDownloader) GetLabels() ([]*Label, error) { | ||
return nil, &ErrNotSupported{Entity: "Labels"} | ||
} | ||
|
||
// GetIssues returns issues according start and limit | ||
func (n NullDownloader) GetIssues(page, perPage int) ([]*Issue, bool, error) { | ||
return nil, false, &ErrNotSupported{Entity: "Issues"} | ||
} | ||
|
||
// GetComments returns comments according issueNumber | ||
func (n NullDownloader) GetComments(issueNumber int64) ([]*Comment, error) { | ||
return nil, &ErrNotSupported{Entity: "Comments"} | ||
} | ||
|
||
// GetPullRequests returns pull requests according page and perPage | ||
func (n NullDownloader) GetPullRequests(page, perPage int) ([]*PullRequest, bool, error) { | ||
return nil, false, &ErrNotSupported{Entity: "PullRequests"} | ||
} | ||
|
||
// GetReviews returns pull requests review | ||
func (n NullDownloader) GetReviews(pullRequestNumber int64) ([]*Review, error) { | ||
return nil, &ErrNotSupported{Entity: "Reviews"} | ||
} | ||
|
||
// FormatCloneURL add authentification into remote URLs | ||
func (n NullDownloader) FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error) { | ||
if len(opts.AuthToken) > 0 || len(opts.AuthUsername) > 0 { | ||
u, err := url.Parse(remoteAddr) | ||
if err != nil { | ||
return "", err | ||
} | ||
u.User = url.UserPassword(opts.AuthUsername, opts.AuthPassword) | ||
if len(opts.AuthToken) > 0 { | ||
u.User = url.UserPassword("oauth2", opts.AuthToken) | ||
} | ||
return u.String(), nil | ||
} | ||
return remoteAddr, nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems incorrect here, because the NullDownloader code returns pointer:
return nil, &ErrNotSupported{}
Or here is correct but NullDownloader does wrong 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed in
dump-repo
git init, fix wrong error type for NullDownloader #20182