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