@@ -90,12 +90,17 @@ func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, passw
90
90
91
91
// split namespace and subdirectory
92
92
pathParts := strings .Split (strings .Trim (repoPath , "/" ), "/" )
93
+ var resp * gitlab.Response
94
+ u , _ := url .Parse (baseURL )
93
95
for len (pathParts ) > 2 {
94
- if _ , _ , err = gitlabClient .Version .GetVersion (); err == nil {
96
+ _ , resp , err = gitlabClient .Version .GetVersion ()
97
+ if err == nil || resp != nil && resp .StatusCode == 401 {
98
+ err = nil // if no authentication given, this still should work
95
99
break
96
100
}
97
101
98
- baseURL = path .Join (baseURL , pathParts [0 ])
102
+ u .Path = path .Join (u .Path , pathParts [0 ])
103
+ baseURL = u .String ()
99
104
pathParts = pathParts [1 :]
100
105
_ = gitlab .WithBaseURL (baseURL )(gitlabClient )
101
106
repoPath = strings .Join (pathParts , "/" )
@@ -105,6 +110,8 @@ func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, passw
105
110
return nil , err
106
111
}
107
112
113
+ log .Trace ("gitlab downloader: use BaseURL: '%s' and RepoPath: '%s'" , baseURL , repoPath )
114
+
108
115
// Grab and store project/repo ID here, due to issues using the URL escaped path
109
116
gr , _ , err := gitlabClient .Projects .GetProject (repoPath , nil , nil , gitlab .WithContext (ctx ))
110
117
if err != nil {
0 commit comments