1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 21:29:42 +02:00

Moved from Dep to Go Modules

We have finally dropped go dep and moved over to go mod !

During the move, some dependencies have been bumped.
This commit is contained in:
HarveyKandola 2019-09-06 11:06:28 +01:00
parent 2c164a135a
commit b826852137
164 changed files with 18268 additions and 10658 deletions

View file

@ -6,6 +6,7 @@
package github
import (
"bytes"
"context"
"fmt"
)
@ -20,7 +21,7 @@ type Blob struct {
NodeID *string `json:"node_id,omitempty"`
}
// GetBlob fetchs a blob from a repo given a SHA.
// GetBlob fetches a blob from a repo given a SHA.
//
// GitHub API docs: https://developer.github.com/v3/git/blobs/#get-a-blob
func (s *GitService) GetBlob(ctx context.Context, owner string, repo string, sha string) (*Blob, *Response, error) {
@ -30,14 +31,28 @@ func (s *GitService) GetBlob(ctx context.Context, owner string, repo string, sha
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview)
blob := new(Blob)
resp, err := s.client.Do(ctx, req, blob)
return blob, resp, err
}
// GetBlobRaw fetches a blob's contents from a repo.
// Unlike GetBlob, it returns the raw bytes rather than the base64-encoded data.
//
// GitHub API docs: https://developer.github.com/v3/git/blobs/#get-a-blob
func (s *GitService) GetBlobRaw(ctx context.Context, owner, repo, sha string) ([]byte, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/git/blobs/%v", owner, repo, sha)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
req.Header.Set("Accept", "application/vnd.github.v3.raw")
var buf bytes.Buffer
resp, err := s.client.Do(ctx, req, &buf)
return buf.Bytes(), resp, err
}
// CreateBlob creates a blob object.
//
// GitHub API docs: https://developer.github.com/v3/git/blobs/#create-a-blob
@ -48,9 +63,6 @@ func (s *GitService) CreateBlob(ctx context.Context, owner string, repo string,
return nil, nil, err
}
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeGraphQLNodeIDPreview)
t := new(Blob)
resp, err := s.client.Do(ctx, req, t)
return t, resp, err