Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate reviews when migrating repository from github #9463

Merged
merged 17 commits into from
Jan 23, 2020
Prev Previous commit
Next Next commit
fix commented state
  • Loading branch information
lunny committed Jan 23, 2020
commit beea95e5d095f5cc924a117c08d3dfb42495fcfc
8 changes: 4 additions & 4 deletions modules/migrations/base/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import "time"

// enumerate all review states
const (
ReviewStatePending = "PENDING"
ReviewStateApproved = "APPROVED"
ReviewStateRequestChanges = "CHANGES_REQUESTED"
ReviewStateComment = "COMMENT"
ReviewStatePending = "PENDING"
ReviewStateApproved = "APPROVED"
ReviewStateChangesRequested = "CHANGES_REQUESTED"
ReviewStateCommented = "COMMENTED"
)

// Review is a standard review information
Expand Down
4 changes: 2 additions & 2 deletions modules/migrations/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,9 @@ func convertReviewState(state string) models.ReviewType {
return models.ReviewTypePending
case base.ReviewStateApproved:
return models.ReviewTypeApprove
case base.ReviewStateRequestChanges:
case base.ReviewStateChangesRequested:
return models.ReviewTypeReject
case base.ReviewStateComment:
case base.ReviewStateCommented:
return models.ReviewTypeComment
default:
return models.ReviewTypePending
Expand Down
24 changes: 23 additions & 1 deletion modules/migrations/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,30 @@ func TestGitHubDownloadRepo(t *testing.T) {
ReviewerName: "lunny",
CommitID: "2be9101c543658591222acbee3eb799edfc3853d",
CreatedAt: time.Date(2020, 01, 04, 06, 07, 06, 0, time.UTC),
State: base.ReviewStateRequestChanges,
State: base.ReviewStateChangesRequested,
Content: "Don't add more reviews",
},
{
ID: 338349019,
IssueIndex: 4,
ReviewerID: 81045,
ReviewerName: "lunny",
CommitID: "2be9101c543658591222acbee3eb799edfc3853d",
CreatedAt: time.Date(2020, 01, 04, 11, 21, 41, 0, time.UTC),
State: base.ReviewStateCommented,
Comments: []*base.ReviewComment{
{
ID: 363029944,
Content: "test a single comment.",
TreePath: "LICENSE",
Position: 4,
CommitID: "2be9101c543658591222acbee3eb799edfc3853d",
PosterID: 81045,
Reactions: &base.Reactions{},
CreatedAt: time.Date(2020, 01, 04, 11, 21, 41, 0, time.UTC),
UpdatedAt: time.Date(2020, 01, 04, 11, 21, 41, 0, time.UTC),
},
},
},
}, reviews)
}