diff options
author | 6543 <6543@obermui.de> | 2020-11-19 06:17:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-19 00:17:56 -0500 |
commit | ad2a288622c7bbf53b8670e136e2e1418331b121 (patch) | |
tree | 0f74280d557faa0fc366b3bb0850888fcc819463 /modules/migrations/gitlab.go | |
parent | 6626a048df511b3833658db8215089b2ed323c64 (diff) | |
download | gitea-ad2a288622c7bbf53b8670e136e2e1418331b121.tar.gz gitea-ad2a288622c7bbf53b8670e136e2e1418331b121.zip |
finaly fix gitlab migration with subdir (#13629)
* finaly fix #13535
* add logging
Diffstat (limited to 'modules/migrations/gitlab.go')
-rw-r--r-- | modules/migrations/gitlab.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/modules/migrations/gitlab.go b/modules/migrations/gitlab.go index 06f4a4ba7f..c510944f6f 100644 --- a/modules/migrations/gitlab.go +++ b/modules/migrations/gitlab.go @@ -90,12 +90,17 @@ func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, passw // split namespace and subdirectory pathParts := strings.Split(strings.Trim(repoPath, "/"), "/") + var resp *gitlab.Response + u, _ := url.Parse(baseURL) for len(pathParts) > 2 { - if _, _, err = gitlabClient.Version.GetVersion(); err == nil { + _, resp, err = gitlabClient.Version.GetVersion() + if err == nil || resp != nil && resp.StatusCode == 401 { + err = nil // if no authentication given, this still should work break } - baseURL = path.Join(baseURL, pathParts[0]) + u.Path = path.Join(u.Path, pathParts[0]) + baseURL = u.String() pathParts = pathParts[1:] _ = gitlab.WithBaseURL(baseURL)(gitlabClient) repoPath = strings.Join(pathParts, "/") @@ -105,6 +110,8 @@ func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, passw return nil, err } + log.Trace("gitlab downloader: use BaseURL: '%s' and RepoPath: '%s'", baseURL, repoPath) + // Grab and store project/repo ID here, due to issues using the URL escaped path gr, _, err := gitlabClient.Projects.GetProject(repoPath, nil, nil, gitlab.WithContext(ctx)) if err != nil { |