Documentation
¶
Overview ¶
Package github reads repository contents from the GitHub API.
It covers what a generator needs to track a file published upstream: find the commit that last touched it, list the tree at that commit, and fetch a file or the whole repository at it. Going through the API rather than cloning keeps the fetch to what is wanted, and yields a commit SHA to record alongside whatever was generated so a result can be traced back to what produced it.
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Blob(ctx context.Context, owner string, repo string, fileSha string, ...) (*blob.Blob, error)
- func (c *Client) CommitArchive(ctx context.Context, owner string, repo string, reference string, ...) (*zip.Reader, error)
- func (c *Client) LatestCommit(ctx context.Context, owner string, repo string, path string, ...) (*commit.Commit, error)
- func (c *Client) Tree(ctx context.Context, owner string, repo string, treeSha string, ...) (*tree.Tree, error)
Constants ¶
const ( DefaultHost = "api.github.com" DefaultArchiveHost = "github.com" )
Variables ¶
var ErrUnexpectedCommitCount = errors.New("unexpected number of commits")
ErrUnexpectedCommitCount reports an answer that does not name exactly the one commit that was asked for.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(options ...github_config.Option) *Client
func (*Client) Blob ¶
func (c *Client) Blob( ctx context.Context, owner string, repo string, fileSha string, options ...fetch_config.Option, ) (*blob.Blob, error)
Blob returns a file's contents.
func (*Client) CommitArchive ¶
func (c *Client) CommitArchive( ctx context.Context, owner string, repo string, reference string, options ...fetch_config.Option, ) (*zip.Reader, error)
CommitArchive returns the repository at a revision, as an archive.
func (*Client) LatestCommit ¶
func (c *Client) LatestCommit( ctx context.Context, owner string, repo string, path string, options ...fetch_config.Option, ) (*commit.Commit, error)
LatestCommit returns the commit that last touched path.
Asking for the commit behind a single path, rather than the head of the branch, is what makes a generated file's provenance meaningful: the SHA names the revision that last changed the thing it was generated from.
Directories
¶
| Path | Synopsis |
|---|---|
|
types
|
|
|
blob
Package blob holds a file's contents as the GitHub API reports them.
|
Package blob holds a file's contents as the GitHub API reports them. |
|
commit
Package commit holds a commit as the GitHub API reports one.
|
Package commit holds a commit as the GitHub API reports one. |
|
tree
Package tree holds a repository listing as the GitHub API reports one.
|
Package tree holds a repository listing as the GitHub API reports one. |