From f6067a8465e7762aea1561106cfee291409a0fd6 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 24 Jan 2020 01:28:15 +0800 Subject: Migrate reviews when migrating repository from github (#9463) * fix typo * Migrate reviews when migrating repository from github * fix lint * Added test and migration when external user login * fix test * fix commented state * Some improvements * fix bug when get pull request and ref original author on code comments * Fix migrated line; Added comment for review * Don't load all pull requests attributes * Fix typo * wrong change copy head * fix tests * fix reactions * Fix test * fix fmt * fix review comment reactions --- modules/migrations/base/downloader.go | 1 + modules/migrations/base/review.go | 44 +++++++++++++++++++++++++++++++++++ modules/migrations/base/uploader.go | 1 + 3 files changed, 46 insertions(+) create mode 100644 modules/migrations/base/review.go (limited to 'modules/migrations/base') diff --git a/modules/migrations/base/downloader.go b/modules/migrations/base/downloader.go index 87ade5c02e..5de8c9513b 100644 --- a/modules/migrations/base/downloader.go +++ b/modules/migrations/base/downloader.go @@ -23,6 +23,7 @@ type Downloader interface { GetIssues(page, perPage int) ([]*Issue, bool, error) GetComments(issueNumber int64) ([]*Comment, error) GetPullRequests(page, perPage int) ([]*PullRequest, error) + GetReviews(pullRequestNumber int64) ([]*Review, error) } // DownloaderFactory defines an interface to match a downloader implementation and create a downloader diff --git a/modules/migrations/base/review.go b/modules/migrations/base/review.go new file mode 100644 index 0000000000..8051fed653 --- /dev/null +++ b/modules/migrations/base/review.go @@ -0,0 +1,44 @@ +// Copyright 2019 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 "time" + +// enumerate all review states +const ( + ReviewStatePending = "PENDING" + ReviewStateApproved = "APPROVED" + ReviewStateChangesRequested = "CHANGES_REQUESTED" + ReviewStateCommented = "COMMENTED" +) + +// Review is a standard review information +type Review struct { + ID int64 + IssueIndex int64 + ReviewerID int64 + ReviewerName string + Official bool + CommitID string + Content string + CreatedAt time.Time + State string // PENDING, APPROVED, REQUEST_CHANGES, or COMMENT + Comments []*ReviewComment +} + +// ReviewComment represents a review comment +type ReviewComment struct { + ID int64 + InReplyTo int64 + Content string + TreePath string + DiffHunk string + Position int + CommitID string + PosterID int64 + Reactions []*Reaction + CreatedAt time.Time + UpdatedAt time.Time +} diff --git a/modules/migrations/base/uploader.go b/modules/migrations/base/uploader.go index 257c7a2909..85ad60fe0e 100644 --- a/modules/migrations/base/uploader.go +++ b/modules/migrations/base/uploader.go @@ -17,6 +17,7 @@ type Uploader interface { CreateIssues(issues ...*Issue) error CreateComments(comments ...*Comment) error CreatePullRequests(prs ...*PullRequest) error + CreateReviews(reviews ...*Review) error Rollback() error Close() } -- cgit v1.2.3