Skip to content

Commit 24b3b21

Browse files
6543lafriks
andauthored
finaly fix gitlab migration with subdir 2.0 (#13646)
* final fix 2.0? * ignore Approvals for pulls if not found * CI.restart() Co-authored-by: Lauris BH <[email protected]>
1 parent 702e82d commit 24b3b21

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

modules/migrations/gitlab.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, passw
9292
pathParts := strings.Split(strings.Trim(repoPath, "/"), "/")
9393
var resp *gitlab.Response
9494
u, _ := url.Parse(baseURL)
95-
for len(pathParts) > 2 {
95+
for len(pathParts) >= 2 {
9696
_, resp, err = gitlabClient.Version.GetVersion()
9797
if err == nil || resp != nil && resp.StatusCode == 401 {
9898
err = nil // if no authentication given, this still should work
@@ -609,8 +609,12 @@ func (g *GitlabDownloader) GetPullRequests(page, perPage int) ([]*base.PullReque
609609

610610
// GetReviews returns pull requests review
611611
func (g *GitlabDownloader) GetReviews(pullRequestNumber int64) ([]*base.Review, error) {
612-
state, _, err := g.client.MergeRequestApprovals.GetApprovalState(g.repoID, int(pullRequestNumber), gitlab.WithContext(g.ctx))
612+
state, resp, err := g.client.MergeRequestApprovals.GetApprovalState(g.repoID, int(pullRequestNumber), gitlab.WithContext(g.ctx))
613613
if err != nil {
614+
if resp != nil && resp.StatusCode == 404 {
615+
log.Error(fmt.Sprintf("GitlabDownloader: while migrating a error occurred: '%s'", err.Error()))
616+
return []*base.Review{}, nil
617+
}
614618
return nil, err
615619
}
616620

0 commit comments

Comments
 (0)