Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
c6ab79ee3c
commit
ed3a4cd103
1 changed files with 18 additions and 0 deletions
|
@ -11,6 +11,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -87,6 +88,23 @@ func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, passw
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// split namespace and subdirectory
|
||||||
|
pathParts := strings.Split(strings.Trim(repoPath, "/"), "/")
|
||||||
|
for len(pathParts) > 2 {
|
||||||
|
if _, _, err = gitlabClient.Version.GetVersion(); err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
baseURL = path.Join(baseURL, pathParts[0])
|
||||||
|
pathParts = pathParts[1:]
|
||||||
|
_ = gitlab.WithBaseURL(baseURL)(gitlabClient)
|
||||||
|
repoPath = strings.Join(pathParts, "/")
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Trace("Error could not get gitlab version: %v", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// 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 {
|
||||||
|
|
Reference in a new issue