gitlab: check getFile exists before content encoding

This commit is contained in:
Luigi Leoni 2019-05-29 15:51:34 +02:00 committed by Simone Gotti
parent 5c4dff0fd9
commit 51a5594c89
1 changed files with 3 additions and 0 deletions

View File

@ -149,6 +149,9 @@ func (c *Client) GetUserInfo() (*gitsource.UserInfo, error) {
func (c *Client) GetFile(repopath, commit, file string) ([]byte, error) {
f, _, err := c.client.RepositoryFiles.GetFile(repopath, file, &gitlab.GetFileOptions{Ref: gitlab.String(commit)})
if err != nil {
return nil, err
}
data, err := base64.StdEncoding.DecodeString(f.Content)
if err != nil {
return nil, err