aboutsummaryrefslogtreecommitdiffstats
path: root/modules/migrations/restore.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2021-08-22 00:47:45 +0200
committerGitHub <noreply@github.com>2021-08-22 00:47:45 +0200
commitcee5f7c5e2bfe3132d7089a6bffc1a4bfc392e21 (patch)
tree41cf982a5b7a759645238fa7a99446e09761d359 /modules/migrations/restore.go
parent2d1935acc7b2a6ecc797346625b80caa7e0b5787 (diff)
downloadgitea-cee5f7c5e2bfe3132d7089a6bffc1a4bfc392e21.tar.gz
gitea-cee5f7c5e2bfe3132d7089a6bffc1a4bfc392e21.zip
Add migrate from OneDev (#16356)
* Use context to simplify logic. * Added migration from OneDev. This PR adds [OneDev](https://code.onedev.io/) as migration source. Supported: - [x] Milestones - [x] Issues - [x] Pull Requests - [x] Comments - [x] Reviews - [x] Labels
Diffstat (limited to 'modules/migrations/restore.go')
-rw-r--r--modules/migrations/restore.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/migrations/restore.go b/modules/migrations/restore.go
index 6177f80cbb..6287d601c2 100644
--- a/modules/migrations/restore.go
+++ b/modules/migrations/restore.go
@@ -208,13 +208,16 @@ func (r *RepositoryRestorer) GetIssues(page, perPage int) ([]*base.Issue, bool,
if err != nil {
return nil, false, err
}
+ for _, issue := range issues {
+ issue.Context = base.BasicIssueContext(issue.Number)
+ }
return issues, true, nil
}
// GetComments returns comments according issueNumber
func (r *RepositoryRestorer) GetComments(opts base.GetCommentOptions) ([]*base.Comment, bool, error) {
var comments = make([]*base.Comment, 0, 10)
- p := filepath.Join(r.commentDir(), fmt.Sprintf("%d.yml", opts.IssueNumber))
+ p := filepath.Join(r.commentDir(), fmt.Sprintf("%d.yml", opts.Context.ForeignID()))
_, err := os.Stat(p)
if err != nil {
if os.IsNotExist(err) {
@@ -258,14 +261,15 @@ func (r *RepositoryRestorer) GetPullRequests(page, perPage int) ([]*base.PullReq
}
for _, pr := range pulls {
pr.PatchURL = "file://" + filepath.Join(r.baseDir, pr.PatchURL)
+ pr.Context = base.BasicIssueContext(pr.Number)
}
return pulls, true, nil
}
// GetReviews returns pull requests review
-func (r *RepositoryRestorer) GetReviews(pullRequestNumber int64) ([]*base.Review, error) {
+func (r *RepositoryRestorer) GetReviews(context base.IssueContext) ([]*base.Review, error) {
var reviews = make([]*base.Review, 0, 10)
- p := filepath.Join(r.reviewDir(), fmt.Sprintf("%d.yml", pullRequestNumber))
+ p := filepath.Join(r.reviewDir(), fmt.Sprintf("%d.yml", context.ForeignID()))
_, err := os.Stat(p)
if err != nil {
if os.IsNotExist(err) {