|
|
@ -90,12 +90,17 @@ func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, passw
|
|
|
|
|
|
|
|
|
|
|
|
// split namespace and subdirectory
|
|
|
|
// split namespace and subdirectory
|
|
|
|
pathParts := strings.Split(strings.Trim(repoPath, "/"), "/")
|
|
|
|
pathParts := strings.Split(strings.Trim(repoPath, "/"), "/")
|
|
|
|
|
|
|
|
var resp *gitlab.Response
|
|
|
|
|
|
|
|
u, _ := url.Parse(baseURL)
|
|
|
|
for len(pathParts) > 2 {
|
|
|
|
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
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
baseURL = path.Join(baseURL, pathParts[0])
|
|
|
|
u.Path = path.Join(u.Path, pathParts[0])
|
|
|
|
|
|
|
|
baseURL = u.String()
|
|
|
|
pathParts = pathParts[1:]
|
|
|
|
pathParts = pathParts[1:]
|
|
|
|
_ = gitlab.WithBaseURL(baseURL)(gitlabClient)
|
|
|
|
_ = gitlab.WithBaseURL(baseURL)(gitlabClient)
|
|
|
|
repoPath = strings.Join(pathParts, "/")
|
|
|
|
repoPath = strings.Join(pathParts, "/")
|
|
|
@ -105,6 +110,8 @@ func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, passw
|
|
|
|
return nil, err
|
|
|
|
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
|
|
|
|
// 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))
|
|
|
|
gr, _, err := gitlabClient.Projects.GetProject(repoPath, nil, nil, gitlab.WithContext(ctx))
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|