Documentation
¶
Overview ¶
Package github is the little of GitHub's REST API that mcloud needs: read files, and commit several file changes at once to a branch.
Index ¶
- Variables
- func Token() (string, error)
- type Change
- type Client
- func (c *Client) Commit(ctx context.Context, repo Repo, branch, message string, ...) (string, error)
- func (c *Client) Commits(ctx context.Context, repo Repo, ref, path string, n int) ([]Commit, error)
- func (c *Client) Dir(ctx context.Context, repo Repo, ref, dir string) ([]string, error)
- func (c *Client) Dispatch(ctx context.Context, repo Repo, workflow, ref string) error
- func (c *Client) Exists(ctx context.Context, repo Repo, ref, p string) (bool, error)
- func (c *Client) File(ctx context.Context, repo Repo, ref, file string) ([]byte, error)
- func (c *Client) Head(ctx context.Context, repo Repo, branch string) (string, error)
- func (c *Client) RepoExists(ctx context.Context, repo Repo) (bool, error)
- func (c *Client) RestoreDir(ctx context.Context, repo Repo, branch, dir, from, message string) (string, error)
- func (c *Client) Run(ctx context.Context, repo Repo, id int64) (*Run, error)
- func (c *Client) RunsFor(ctx context.Context, repo Repo, sha string) ([]Run, error)
- type Commit
- type Reader
- type Repo
- type Run
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is returned for a missing repo, branch or file.
Functions ¶
Types ¶
type Client ¶
type Client struct {
BaseURL string // https://api.github.com
Token string
HTTP *http.Client
}
func (*Client) Commit ¶
func (c *Client) Commit(ctx context.Context, repo Repo, branch, message string, plan func(Reader) ([]Change, error)) (string, error)
Commit builds one commit on branch from the changes plan returns, and moves the branch to it. If the branch moves in the meantime, it starts over from the new head, so plan must be safe to call more than once. A plan that returns no changes makes no commit. Returns the new commit's SHA.
func (*Client) Commits ¶ added in v0.17.0
Commits lists the newest commits reachable from ref (a branch or SHA) that change path, newest first, at most n (up to 100).
func (*Client) Dir ¶ added in v0.17.0
Dir lists the names of the files in a directory at ref; ErrNotFound if there's no such directory.
func (*Client) RepoExists ¶
RepoExists reports whether the token can see the repo.
func (*Client) RestoreDir ¶ added in v0.17.0
func (c *Client) RestoreDir(ctx context.Context, repo Repo, branch, dir, from, message string) (string, error)
RestoreDir commits dir on branch as it was at commit from: one new commit on top of the branch's head (no history is rewritten), with the files from then and without those added since. The rest of the repo stays as it is. Returns the new commit's SHA, or "" if dir is already like that.
type Commit ¶ added in v0.17.0
type Commit struct {
SHA string
Message string
Author string // GitHub login, else the git author's name
Date time.Time
}
Commit is one commit, as a history lists it.
type Run ¶
type Run struct {
ID int64 `json:"id"`
Name string `json:"name"`
Status string `json:"status"` // queued, in_progress, completed, ...
Conclusion string `json:"conclusion"` // success, failure, cancelled, ...
HTMLURL string `json:"html_url"`
Event string `json:"event"`
Path string `json:"path"` // the workflow file: .github/workflows/deploy.yaml
}
Run is a GitHub Actions workflow run.