aboutsummaryrefslogtreecommitdiffstats
path: root/modules/migrations/gitlab.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2021-08-18 02:47:18 +0200
committerGitHub <noreply@github.com>2021-08-17 20:47:18 -0400
commit422c30d3157d9f06af43901a1c7978dd25ca12a5 (patch)
tree57e7cf2f93405a0557578dc21ff9488ab48e4333 /modules/migrations/gitlab.go
parent65c6acccf693a8d2eb70d59df38d5c3528188390 (diff)
downloadgitea-422c30d3157d9f06af43901a1c7978dd25ca12a5.tar.gz
gitea-422c30d3157d9f06af43901a1c7978dd25ca12a5.zip
Refactored and fixed migration tests. (#16714)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'modules/migrations/gitlab.go')
-rw-r--r--modules/migrations/gitlab.go21
1 files changed, 6 insertions, 15 deletions
diff --git a/modules/migrations/gitlab.go b/modules/migrations/gitlab.go
index fe763f9900..1050ffd0c9 100644
--- a/modules/migrations/gitlab.go
+++ b/modules/migrations/gitlab.go
@@ -609,7 +609,7 @@ func (g *GitlabDownloader) GetPullRequests(page, perPage int) ([]*base.PullReque
// GetReviews returns pull requests review
func (g *GitlabDownloader) GetReviews(pullRequestNumber int64) ([]*base.Review, error) {
- state, resp, err := g.client.MergeRequestApprovals.GetApprovalState(g.repoID, int(pullRequestNumber), gitlab.WithContext(g.ctx))
+ approvals, resp, err := g.client.MergeRequestApprovals.GetConfiguration(g.repoID, int(pullRequestNumber), gitlab.WithContext(g.ctx))
if err != nil {
if resp != nil && resp.StatusCode == 404 {
log.Error(fmt.Sprintf("GitlabDownloader: while migrating a error occurred: '%s'", err.Error()))
@@ -618,21 +618,12 @@ func (g *GitlabDownloader) GetReviews(pullRequestNumber int64) ([]*base.Review,
return nil, err
}
- // GitLab's Approvals are equivalent to Gitea's approve reviews
- approvers := make(map[int]string)
- for i := range state.Rules {
- for u := range state.Rules[i].ApprovedBy {
- approvers[state.Rules[i].ApprovedBy[u].ID] = state.Rules[i].ApprovedBy[u].Username
- }
- }
-
- var reviews = make([]*base.Review, 0, len(approvers))
- for id, name := range approvers {
+ var reviews = make([]*base.Review, 0, len(approvals.ApprovedBy))
+ for _, user := range approvals.ApprovedBy {
reviews = append(reviews, &base.Review{
- ReviewerID: int64(id),
- ReviewerName: name,
- // GitLab API doesn't return a creation date
- CreatedAt: time.Now(),
+ ReviewerID: int64(user.User.ID),
+ ReviewerName: user.User.Username,
+ CreatedAt: *approvals.UpdatedAt,
// All we get are approvals
State: base.ReviewStateApproved,
})