aboutsummaryrefslogtreecommitdiffstats
path: root/services/migrations/gitea_uploader.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/migrations/gitea_uploader.go')
-rw-r--r--services/migrations/gitea_uploader.go82
1 files changed, 41 insertions, 41 deletions
diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go
index 408704adef..e71b2ca17a 100644
--- a/services/migrations/gitea_uploader.go
+++ b/services/migrations/gitea_uploader.go
@@ -45,14 +45,14 @@ type GiteaLocalUploader struct {
repoOwner string
repoName string
repo *repo_model.Repository
- labels map[string]*models.Label
+ labels map[string]*issues_model.Label
milestones map[string]int64
- issues map[int64]*models.Issue
+ issues map[int64]*issues_model.Issue
gitRepo *git.Repository
prHeadCache map[string]struct{}
sameApp bool
userMap map[int64]int64 // external user id mapping to user id
- prCache map[int64]*models.PullRequest
+ prCache map[int64]*issues_model.PullRequest
gitServiceType structs.GitServiceType
}
@@ -63,12 +63,12 @@ func NewGiteaLocalUploader(ctx context.Context, doer *user_model.User, repoOwner
doer: doer,
repoOwner: repoOwner,
repoName: repoName,
- labels: make(map[string]*models.Label),
+ labels: make(map[string]*issues_model.Label),
milestones: make(map[string]int64),
- issues: make(map[int64]*models.Issue),
+ issues: make(map[int64]*issues_model.Issue),
prHeadCache: make(map[string]struct{}),
userMap: make(map[int64]int64),
- prCache: make(map[int64]*models.PullRequest),
+ prCache: make(map[int64]*issues_model.PullRequest),
}
}
@@ -76,17 +76,17 @@ func NewGiteaLocalUploader(ctx context.Context, doer *user_model.User, repoOwner
func (g *GiteaLocalUploader) MaxBatchInsertSize(tp string) int {
switch tp {
case "issue":
- return db.MaxBatchInsertSize(new(models.Issue))
+ return db.MaxBatchInsertSize(new(issues_model.Issue))
case "comment":
- return db.MaxBatchInsertSize(new(models.Comment))
+ return db.MaxBatchInsertSize(new(issues_model.Comment))
case "milestone":
return db.MaxBatchInsertSize(new(issues_model.Milestone))
case "label":
- return db.MaxBatchInsertSize(new(models.Label))
+ return db.MaxBatchInsertSize(new(issues_model.Label))
case "release":
return db.MaxBatchInsertSize(new(models.Release))
case "pullrequest":
- return db.MaxBatchInsertSize(new(models.PullRequest))
+ return db.MaxBatchInsertSize(new(issues_model.PullRequest))
}
return 10
}
@@ -216,9 +216,9 @@ func (g *GiteaLocalUploader) CreateMilestones(milestones ...*base.Milestone) err
// CreateLabels creates labels
func (g *GiteaLocalUploader) CreateLabels(labels ...*base.Label) error {
- lbs := make([]*models.Label, 0, len(labels))
+ lbs := make([]*issues_model.Label, 0, len(labels))
for _, label := range labels {
- lbs = append(lbs, &models.Label{
+ lbs = append(lbs, &issues_model.Label{
RepoID: g.repo.ID,
Name: label.Name,
Description: label.Description,
@@ -226,7 +226,7 @@ func (g *GiteaLocalUploader) CreateLabels(labels ...*base.Label) error {
})
}
- err := models.NewLabels(lbs...)
+ err := issues_model.NewLabels(lbs...)
if err != nil {
return err
}
@@ -339,9 +339,9 @@ func (g *GiteaLocalUploader) SyncTags() error {
// CreateIssues creates issues
func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error {
- iss := make([]*models.Issue, 0, len(issues))
+ iss := make([]*issues_model.Issue, 0, len(issues))
for _, issue := range issues {
- var labels []*models.Label
+ var labels []*issues_model.Label
for _, label := range issue.Labels {
lb, ok := g.labels[label.Name]
if ok {
@@ -366,7 +366,7 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error {
}
}
- is := models.Issue{
+ is := issues_model.Issue{
RepoID: g.repo.ID,
Repo: g.repo,
Index: issue.Number,
@@ -423,9 +423,9 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error {
// CreateComments creates comments of issues
func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error {
- cms := make([]*models.Comment, 0, len(comments))
+ cms := make([]*issues_model.Comment, 0, len(comments))
for _, comment := range comments {
- var issue *models.Issue
+ var issue *issues_model.Issue
issue, ok := g.issues[comment.IssueIndex]
if !ok {
return fmt.Errorf("comment references non existent IssueIndex %d", comment.IssueIndex)
@@ -438,9 +438,9 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error {
comment.Updated = comment.Created
}
- cm := models.Comment{
+ cm := issues_model.Comment{
IssueID: issue.ID,
- Type: models.CommentTypeComment,
+ Type: issues_model.CommentTypeComment,
Content: comment.Content,
CreatedUnix: timeutil.TimeStamp(comment.Created.Unix()),
UpdatedUnix: timeutil.TimeStamp(comment.Updated.Unix()),
@@ -473,7 +473,7 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error {
// CreatePullRequests creates pull requests
func (g *GiteaLocalUploader) CreatePullRequests(prs ...*base.PullRequest) error {
- gprs := make([]*models.PullRequest, 0, len(prs))
+ gprs := make([]*issues_model.PullRequest, 0, len(prs))
for _, pr := range prs {
gpr, err := g.newPullRequest(pr)
if err != nil {
@@ -600,8 +600,8 @@ func (g *GiteaLocalUploader) updateGitForPullRequest(pr *base.PullRequest) (head
return head, nil
}
-func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullRequest, error) {
- var labels []*models.Label
+func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*issues_model.PullRequest, error) {
+ var labels []*issues_model.Label
for _, label := range pr.Labels {
lb, ok := g.labels[label.Name]
if ok {
@@ -629,7 +629,7 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR
pr.Updated = pr.Created
}
- issue := models.Issue{
+ issue := issues_model.Issue{
RepoID: g.repo.ID,
Repo: g.repo,
Title: pr.Title,
@@ -660,7 +660,7 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR
issue.Reactions = append(issue.Reactions, &res)
}
- pullRequest := models.PullRequest{
+ pullRequest := issues_model.PullRequest{
HeadRepoID: g.repo.ID,
HeadBranch: head,
BaseRepoID: g.repo.ID,
@@ -686,28 +686,28 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR
return &pullRequest, nil
}
-func convertReviewState(state string) models.ReviewType {
+func convertReviewState(state string) issues_model.ReviewType {
switch state {
case base.ReviewStatePending:
- return models.ReviewTypePending
+ return issues_model.ReviewTypePending
case base.ReviewStateApproved:
- return models.ReviewTypeApprove
+ return issues_model.ReviewTypeApprove
case base.ReviewStateChangesRequested:
- return models.ReviewTypeReject
+ return issues_model.ReviewTypeReject
case base.ReviewStateCommented:
- return models.ReviewTypeComment
+ return issues_model.ReviewTypeComment
case base.ReviewStateRequestReview:
- return models.ReviewTypeRequest
+ return issues_model.ReviewTypeRequest
default:
- return models.ReviewTypePending
+ return issues_model.ReviewTypePending
}
}
// CreateReviews create pull request reviews of currently migrated issues
func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
- cms := make([]*models.Review, 0, len(reviews))
+ cms := make([]*issues_model.Review, 0, len(reviews))
for _, review := range reviews {
- var issue *models.Issue
+ var issue *issues_model.Issue
issue, ok := g.issues[review.IssueIndex]
if !ok {
return fmt.Errorf("review references non existent IssueIndex %d", review.IssueIndex)
@@ -716,7 +716,7 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
review.CreatedAt = time.Unix(int64(issue.CreatedUnix), 0)
}
- cm := models.Review{
+ cm := issues_model.Review{
Type: convertReviewState(review.State),
IssueID: issue.ID,
Content: review.Content,
@@ -733,7 +733,7 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
pr, ok := g.prCache[issue.ID]
if !ok {
var err error
- pr, err = models.GetPullRequestByIssueIDWithNoAttributes(issue.ID)
+ pr, err = issues_model.GetPullRequestByIssueIDWithNoAttributes(issue.ID)
if err != nil {
return err
}
@@ -767,7 +767,7 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
_ = writer.Close()
}(comment)
- patch, _ = git.CutDiffAroundLine(reader, int64((&models.Comment{Line: int64(line + comment.Position - 1)}).UnsignedLine()), line < 0, setting.UI.CodeCommentLines)
+ patch, _ = git.CutDiffAroundLine(reader, int64((&issues_model.Comment{Line: int64(line + comment.Position - 1)}).UnsignedLine()), line < 0, setting.UI.CodeCommentLines)
if comment.CreatedAt.IsZero() {
comment.CreatedAt = review.CreatedAt
@@ -776,8 +776,8 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
comment.UpdatedAt = comment.CreatedAt
}
- c := models.Comment{
- Type: models.CommentTypeCode,
+ c := issues_model.Comment{
+ Type: issues_model.CommentTypeCode,
IssueID: issue.ID,
Content: comment.Content,
Line: int64(line + comment.Position - 1),
@@ -798,7 +798,7 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
cms = append(cms, &cm)
}
- return models.InsertReviews(cms)
+ return issues_model.InsertReviews(cms)
}
// Rollback when migrating failed, this will rollback all the changes.
@@ -819,7 +819,7 @@ func (g *GiteaLocalUploader) Finish() error {
}
// update issue_index
- if err := models.RecalculateIssueIndexForRepo(g.repo.ID); err != nil {
+ if err := issues_model.RecalculateIssueIndexForRepo(g.repo.ID); err != nil {
return err
}