|
|
|
@ -53,6 +53,26 @@ func (fm *FetchMigratory) MigrateFromGitHub() error { |
|
|
|
|
"repo": fmt.Sprintf("%s/%s", fm.RepoOwner, fm.RepoName), |
|
|
|
|
}).Info("git repository migrated") |
|
|
|
|
if fm.Options.Issues || fm.Options.PullRequests { |
|
|
|
|
if err := fm.MigrateIssuesFromGitHub(); err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if fm.Status.FatalError != nil { |
|
|
|
|
fm.Status.Stage = Failed |
|
|
|
|
fm.Logger.WithFields(logrus.Fields{ |
|
|
|
|
"repo": fmt.Sprintf("%s/%s", fm.RepoOwner, fm.RepoName), |
|
|
|
|
}).Errorf("migration failed: %v", fm.Status.FatalError) |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
fm.Status.Stage = Finished |
|
|
|
|
fm.Logger.WithFields(logrus.Fields{ |
|
|
|
|
"repo": fmt.Sprintf("%s/%s", fm.RepoOwner, fm.RepoName), |
|
|
|
|
}).Info("migration successful") |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MigrateIssuesFromGitHub migrates all issues from GitHub to Gitea
|
|
|
|
|
func (fm *FetchMigratory) MigrateIssuesFromGitHub() error { |
|
|
|
|
var commentsChan chan *[]*github.IssueComment |
|
|
|
|
if fm.Options.Comments { |
|
|
|
|
commentsChan = fm.fetchCommentsAsync() |
|
|
|
@ -91,17 +111,23 @@ func (fm *FetchMigratory) MigrateFromGitHub() error { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if fm.Options.Comments { |
|
|
|
|
return fm.MigrateCommentsFromGitHub() |
|
|
|
|
} |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (fm *FetchMigratory) MigrateCommentsFromGitHub() error { |
|
|
|
|
var comments []*github.IssueComment |
|
|
|
|
if cmts := <-commentsChan; cmts == nil { |
|
|
|
|
var cmts *[]*github.IssueComment |
|
|
|
|
if cmts = <-commentsChan; cmts == nil { |
|
|
|
|
fm.Status.Stage = Failed |
|
|
|
|
err := fmt.Errorf("error while fetching issue comments") |
|
|
|
|
fm.Logger.WithFields(logrus.Fields{ |
|
|
|
|
"repo": fmt.Sprintf("%s/%s", fm.RepoOwner, fm.RepoName), |
|
|
|
|
}).Errorf("migration failed: %v", fm.Status.FatalError) |
|
|
|
|
return err |
|
|
|
|
} else { |
|
|
|
|
comments = *cmts |
|
|
|
|
} |
|
|
|
|
comments = *cmts |
|
|
|
|
if err != nil { |
|
|
|
|
fm.Status.Stage = Failed |
|
|
|
|
fm.Status.FatalError = err |
|
|
|
@ -157,20 +183,6 @@ func (fm *FetchMigratory) MigrateFromGitHub() error { |
|
|
|
|
}(issue, comms) |
|
|
|
|
} |
|
|
|
|
wg.Wait() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if fm.Status.FatalError != nil { |
|
|
|
|
fm.Status.Stage = Failed |
|
|
|
|
fm.Logger.WithFields(logrus.Fields{ |
|
|
|
|
"repo": fmt.Sprintf("%s/%s", fm.RepoOwner, fm.RepoName), |
|
|
|
|
}).Errorf("migration failed: %v", fm.Status.FatalError) |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
fm.Status.Stage = Finished |
|
|
|
|
fm.Logger.WithFields(logrus.Fields{ |
|
|
|
|
"repo": fmt.Sprintf("%s/%s", fm.RepoOwner, fm.RepoName), |
|
|
|
|
}).Info("migration successful") |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var issueIndexRegex = regexp.MustCompile(`/(issues|pull)/([0-9]+)#`) |
|
|
|
|