aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/google/go-github/github/repos_contents.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/google/go-github/github/repos_contents.go')
-rw-r--r--vendor/github.com/google/go-github/github/repos_contents.go37
1 files changed, 11 insertions, 26 deletions
diff --git a/vendor/github.com/google/go-github/github/repos_contents.go b/vendor/github.com/google/go-github/github/repos_contents.go
index 7b08cf0..32b1573 100644
--- a/vendor/github.com/google/go-github/github/repos_contents.go
+++ b/vendor/github.com/google/go-github/github/repos_contents.go
@@ -4,14 +4,13 @@
// license that can be found in the LICENSE file.
// Repository contents API methods.
-// http://developer.github.com/v3/repos/contents/
+// https://developer.github.com/v3/repos/contents/
package github
import (
"encoding/base64"
"encoding/json"
- "errors"
"fmt"
"io"
"net/http"
@@ -64,20 +63,6 @@ func (r RepositoryContent) String() string {
return Stringify(r)
}
-// Decode decodes the file content if it is base64 encoded.
-//
-// Deprecated: Use GetContent instead.
-func (r *RepositoryContent) Decode() ([]byte, error) {
- if *r.Encoding != "base64" {
- return nil, errors.New("cannot decode non-base64")
- }
- o, err := base64.StdEncoding.DecodeString(*r.Content)
- if err != nil {
- return nil, err
- }
- return o, nil
-}
-
// GetContent returns the content of r, decoding it if necessary.
func (r *RepositoryContent) GetContent() (string, error) {
var encoding string
@@ -101,7 +86,7 @@ func (r *RepositoryContent) GetContent() (string, error) {
// GetReadme gets the Readme file for the repository.
//
-// GitHub API docs: http://developer.github.com/v3/repos/contents/#get-the-readme
+// GitHub API docs: https://developer.github.com/v3/repos/contents/#get-the-readme
func (s *RepositoriesService) GetReadme(owner, repo string, opt *RepositoryContentGetOptions) (*RepositoryContent, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/readme", owner, repo)
u, err := addOptions(u, opt)
@@ -117,7 +102,7 @@ func (s *RepositoriesService) GetReadme(owner, repo string, opt *RepositoryConte
if err != nil {
return nil, resp, err
}
- return readme, resp, err
+ return readme, resp, nil
}
// DownloadContents returns an io.ReadCloser that reads the contents of the
@@ -153,7 +138,7 @@ func (s *RepositoriesService) DownloadContents(owner, repo, filepath string, opt
// as possible, both result types will be returned but only one will contain a
// value and the other will be nil.
//
-// GitHub API docs: http://developer.github.com/v3/repos/contents/#get-contents
+// GitHub API docs: https://developer.github.com/v3/repos/contents/#get-contents
func (s *RepositoriesService) GetContents(owner, repo, path string, opt *RepositoryContentGetOptions) (fileContent *RepositoryContent, directoryContent []*RepositoryContent, resp *Response, err error) {
escapedPath := (&url.URL{Path: path}).String()
u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, escapedPath)
@@ -184,7 +169,7 @@ func (s *RepositoriesService) GetContents(owner, repo, path string, opt *Reposit
// CreateFile creates a new file in a repository at the given path and returns
// the commit and file metadata.
//
-// GitHub API docs: http://developer.github.com/v3/repos/contents/#create-a-file
+// GitHub API docs: https://developer.github.com/v3/repos/contents/#create-a-file
func (s *RepositoriesService) CreateFile(owner, repo, path string, opt *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) {
u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path)
req, err := s.client.NewRequest("PUT", u, opt)
@@ -196,13 +181,13 @@ func (s *RepositoriesService) CreateFile(owner, repo, path string, opt *Reposito
if err != nil {
return nil, resp, err
}
- return createResponse, resp, err
+ return createResponse, resp, nil
}
// UpdateFile updates a file in a repository at the given path and returns the
// commit and file metadata. Requires the blob SHA of the file being updated.
//
-// GitHub API docs: http://developer.github.com/v3/repos/contents/#update-a-file
+// GitHub API docs: https://developer.github.com/v3/repos/contents/#update-a-file
func (s *RepositoriesService) UpdateFile(owner, repo, path string, opt *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) {
u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path)
req, err := s.client.NewRequest("PUT", u, opt)
@@ -214,13 +199,13 @@ func (s *RepositoriesService) UpdateFile(owner, repo, path string, opt *Reposito
if err != nil {
return nil, resp, err
}
- return updateResponse, resp, err
+ return updateResponse, resp, nil
}
// DeleteFile deletes a file from a repository and returns the commit.
// Requires the blob SHA of the file to be deleted.
//
-// GitHub API docs: http://developer.github.com/v3/repos/contents/#delete-a-file
+// GitHub API docs: https://developer.github.com/v3/repos/contents/#delete-a-file
func (s *RepositoriesService) DeleteFile(owner, repo, path string, opt *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) {
u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path)
req, err := s.client.NewRequest("DELETE", u, opt)
@@ -232,7 +217,7 @@ func (s *RepositoriesService) DeleteFile(owner, repo, path string, opt *Reposito
if err != nil {
return nil, resp, err
}
- return deleteResponse, resp, err
+ return deleteResponse, resp, nil
}
// archiveFormat is used to define the archive type when calling GetArchiveLink.
@@ -250,7 +235,7 @@ const (
// repository. The archiveFormat can be specified by either the github.Tarball
// or github.Zipball constant.
//
-// GitHub API docs: http://developer.github.com/v3/repos/contents/#get-archive-link
+// GitHub API docs: https://developer.github.com/v3/repos/contents/#get-archive-link
func (s *RepositoriesService) GetArchiveLink(owner, repo string, archiveformat archiveFormat, opt *RepositoryContentGetOptions) (*url.URL, *Response, error) {
u := fmt.Sprintf("repos/%s/%s/%s", owner, repo, archiveformat)
if opt != nil && opt.Ref != "" {