Fix in bugs
This commit is contained in:
15
gitlab.go
15
gitlab.go
@@ -9,6 +9,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
|
|
||||||
@@ -60,8 +61,9 @@ func NewGitLabClient(source Source) (*gitlabClient, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &gitlabClient{
|
return &gitlabClient{
|
||||||
client: client,
|
client: client,
|
||||||
repository: source.Repository,
|
repository: source.Repository,
|
||||||
|
accessToken: source.AccessToken,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,13 +238,22 @@ func (g *gitlabClient) DownloadProjectFile(filePath, destPath string) error {
|
|||||||
}
|
}
|
||||||
defer out.Close()
|
defer out.Close()
|
||||||
|
|
||||||
|
// e.g. (group/project) + (/uploads/hash/filename)
|
||||||
filePathRef, err := url.Parse(g.repository + filePath)
|
filePathRef, err := url.Parse(g.repository + filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// e.g. (https://gitlab-instance/api/v4) + (/group/project/uploads/hash/filename)
|
||||||
projectFileUrl := g.client.BaseURL().ResolveReference(filePathRef)
|
projectFileUrl := g.client.BaseURL().ResolveReference(filePathRef)
|
||||||
|
|
||||||
|
// https://gitlab.com/gitlab-org/gitlab-ce/issues/51447
|
||||||
|
nonApiUrl := strings.Replace(projectFileUrl.String(), "/api/v4", "", 1)
|
||||||
|
projectFileUrl, err = url.Parse(nonApiUrl)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
req, err := http.NewRequest("GET", projectFileUrl.String(), nil)
|
req, err := http.NewRequest("GET", projectFileUrl.String(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user