Commit 3f3acb6a authored by Sander van Harmelen's avatar Sander van Harmelen

Update styling a bit

parent 729207a1
......@@ -67,7 +67,11 @@ func (s *RepositoryFilesService) GetFile(pid interface{}, fileName string, opt *
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/files/%s", url.QueryEscape(project), url.PathEscape(fileName))
u := fmt.Sprintf(
"projects/%s/repository/files/%s",
url.QueryEscape(project),
url.PathEscape(fileName),
)
req, err := s.client.NewRequest("GET", u, opt, options)
if err != nil {
......@@ -91,8 +95,8 @@ type GetFileMetaDataOptions struct {
Ref *string `url:"ref,omitempty" json:"ref,omitempty"`
}
// GetFileMetaData allows you to receive meta information about a file in repository like
// name, size.
// GetFileMetaData allows you to receive meta information about a file in
// repository like name, size.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/repository_files.html#get-file-from-repository
......@@ -101,25 +105,31 @@ func (s *RepositoryFilesService) GetFileMetaData(pid interface{}, fileName strin
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/files/%s", url.QueryEscape(project), url.PathEscape(fileName))
u := fmt.Sprintf(
"projects/%s/repository/files/%s",
url.QueryEscape(project),
url.PathEscape(fileName),
)
req, err := s.client.NewRequest("HEAD", u, opt, options)
if err != nil {
return nil, nil, err
}
f := new(File)
resp, err := s.client.Do(req, nil)
if err != nil {
return nil, resp, err
}
f.BlobID = resp.Header.Get("X-Gitlab-Blob-Id")
f.CommitID = resp.Header.Get("X-Gitlab-Last-Commit-Id")
f.Encoding = resp.Header.Get("X-Gitlab-Encoding")
f.FileName = resp.Header.Get("X-Gitlab-File-Name")
f.FilePath = resp.Header.Get("X-Gitlab-File-Path")
f.Ref = resp.Header.Get("X-Gitlab-Ref")
f := &File{
BlobID: resp.Header.Get("X-Gitlab-Blob-Id"),
CommitID: resp.Header.Get("X-Gitlab-Last-Commit-Id"),
Encoding: resp.Header.Get("X-Gitlab-Encoding"),
FileName: resp.Header.Get("X-Gitlab-File-Name"),
FilePath: resp.Header.Get("X-Gitlab-File-Path"),
Ref: resp.Header.Get("X-Gitlab-Ref"),
}
if sizeString := resp.Header.Get("X-Gitlab-Size"); sizeString != "" {
f.Size, err = strconv.Atoi(sizeString)
if err != nil {
......@@ -147,7 +157,11 @@ func (s *RepositoryFilesService) GetRawFile(pid interface{}, fileName string, op
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/files/%s/raw", url.QueryEscape(project), url.PathEscape(fileName))
u := fmt.Sprintf(
"projects/%s/repository/files/%s/raw",
url.QueryEscape(project),
url.PathEscape(fileName),
)
req, err := s.client.NewRequest("GET", u, opt, options)
if err != nil {
......@@ -197,7 +211,11 @@ func (s *RepositoryFilesService) CreateFile(pid interface{}, fileName string, op
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/files/%s", url.QueryEscape(project), url.PathEscape(fileName))
u := fmt.Sprintf(
"projects/%s/repository/files/%s",
url.QueryEscape(project),
url.PathEscape(fileName),
)
req, err := s.client.NewRequest("POST", u, opt, options)
if err != nil {
......@@ -236,7 +254,11 @@ func (s *RepositoryFilesService) UpdateFile(pid interface{}, fileName string, op
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/files/%s", url.QueryEscape(project), url.PathEscape(fileName))
u := fmt.Sprintf(
"projects/%s/repository/files/%s",
url.QueryEscape(project),
url.PathEscape(fileName),
)
req, err := s.client.NewRequest("PUT", u, opt, options)
if err != nil {
......@@ -272,7 +294,11 @@ func (s *RepositoryFilesService) DeleteFile(pid interface{}, fileName string, op
if err != nil {
return nil, err
}
u := fmt.Sprintf("projects/%s/repository/files/%s", url.QueryEscape(project), url.PathEscape(fileName))
u := fmt.Sprintf(
"projects/%s/repository/files/%s",
url.QueryEscape(project),
url.PathEscape(fileName),
)
req, err := s.client.NewRequest("DELETE", u, opt, options)
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment