mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-07-06 22:00:03 +02:00
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
This commit is contained in:
parent
2d1935acc7
commit
cee5f7c5e2
24 changed files with 1093 additions and 92 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue