Documentation
¶
Overview ¶
Package github implements provider.Provider against the GitHub REST API using google/go-github. The go-github package is imported under the alias gh to avoid colliding with this package's own name.
Phase 0 note: PushCommits writes through the Git Data API rather than a local clone. See the package README section on PushCommits for the Phase 1 caveat.
Index ¶
- type Client
- func (c *Client) AddIssueLabel(ctx context.Context, repo provider.Repo, issueNumber int, label string) error
- func (c *Client) ClosePullRequest(ctx context.Context, repo provider.Repo, number int) error
- func (c *Client) CommentOnIssue(ctx context.Context, repo provider.Repo, issueNumber int, body string) error
- func (c *Client) CommentOnPullRequest(ctx context.Context, repo provider.Repo, number int, body string) error
- func (c *Client) CreateBranch(ctx context.Context, repo provider.Repo, branch, fromRef string) error
- func (c *Client) DefaultBranch(ctx context.Context, repo provider.Repo) (string, error)
- func (c *Client) DeleteBranch(ctx context.Context, repo provider.Repo, branch string) error
- func (c *Client) FindOpenPullRequestByHead(ctx context.Context, repo provider.Repo, headBranch string) (*provider.PullRequest, error)
- func (c *Client) GetIssue(ctx context.Context, repo provider.Repo, number int) (*provider.Issue, error)
- func (c *Client) GetPullRequest(ctx context.Context, repo provider.Repo, number int) (*provider.PullRequest, error)
- func (c *Client) ListLabeledIssues(ctx context.Context, repo provider.Repo, label string) ([]provider.Issue, error)
- func (c *Client) ListRepoDir(ctx context.Context, repo provider.Repo, ref, path string) ([]string, error)
- func (c *Client) MergePullRequest(ctx context.Context, repo provider.Repo, number int, ...) error
- func (c *Client) Name() string
- func (c *Client) OpenPullRequest(ctx context.Context, repo provider.Repo, spec provider.PullRequestSpec) (*provider.PullRequest, error)
- func (c *Client) PushCommits(ctx context.Context, repo provider.Repo, branch string, ...) (string, error)
- func (c *Client) ReadRepoFile(ctx context.Context, repo provider.Repo, ref, path string) (string, error)
- func (c *Client) RemoveIssueLabel(ctx context.Context, repo provider.Repo, issueNumber int, label string) error
- func (c *Client) UpdatePullRequestBase(ctx context.Context, repo provider.Repo, number int, baseBranch string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client adapts the GitHub API to provider.Provider.
func New ¶
New builds a GitHub-backed provider authenticated with token. When apiBaseURL is non-empty it targets a GitHub Enterprise Server instance; otherwise it targets github.com.
func (*Client) AddIssueLabel ¶
func (c *Client) AddIssueLabel(ctx context.Context, repo provider.Repo, issueNumber int, label string) error
AddIssueLabel adds label to the issue.
func (*Client) ClosePullRequest ¶
ClosePullRequest closes the pull request without merging.
func (*Client) CommentOnIssue ¶
func (c *Client) CommentOnIssue(ctx context.Context, repo provider.Repo, issueNumber int, body string) error
CommentOnIssue posts body as a comment on the issue.
func (*Client) CommentOnPullRequest ¶
func (c *Client) CommentOnPullRequest(ctx context.Context, repo provider.Repo, number int, body string) error
CommentOnPullRequest posts body as a comment on the pull request. On GitHub a PR is also an issue (shared numbering), so this uses the same issue-comment endpoint as CommentOnIssue.
func (*Client) CreateBranch ¶
func (c *Client) CreateBranch(ctx context.Context, repo provider.Repo, branch, fromRef string) error
CreateBranch creates branch pointing at fromRef (a branch name or SHA).
func (*Client) DefaultBranch ¶
DefaultBranch returns the repo's default branch name.
func (*Client) DeleteBranch ¶
DeleteBranch deletes branch.
func (*Client) FindOpenPullRequestByHead ¶
func (c *Client) FindOpenPullRequestByHead(ctx context.Context, repo provider.Repo, headBranch string) (*provider.PullRequest, error)
FindOpenPullRequestByHead returns an open pull request for headBranch, or nil.
func (*Client) GetIssue ¶
func (c *Client) GetIssue(ctx context.Context, repo provider.Repo, number int) (*provider.Issue, error)
GetIssue fetches a single issue by number, without its comment thread.
func (*Client) GetPullRequest ¶
func (c *Client) GetPullRequest(ctx context.Context, repo provider.Repo, number int) (*provider.PullRequest, error)
GetPullRequest fetches a pull request by number regardless of its state.
func (*Client) ListLabeledIssues ¶
func (c *Client) ListLabeledIssues(ctx context.Context, repo provider.Repo, label string) ([]provider.Issue, error)
ListLabeledIssues returns open issues carrying label. The GitHub issues API also returns pull requests, so those are skipped via IsPullRequest.
func (*Client) ListRepoDir ¶
func (c *Client) ListRepoDir(ctx context.Context, repo provider.Repo, ref, path string) ([]string, error)
ListRepoDir returns the entry names at path, at ref (the repo's default branch when ref is empty). Directory entries are suffixed with "/". The empty path lists the repo root.
func (*Client) MergePullRequest ¶
func (c *Client) MergePullRequest(ctx context.Context, repo provider.Repo, number int, opts provider.MergeOptions) error
MergePullRequest merges the pull request identified by number, optionally deleting its head branch afterwards.
func (*Client) OpenPullRequest ¶
func (c *Client) OpenPullRequest(ctx context.Context, repo provider.Repo, spec provider.PullRequestSpec) (*provider.PullRequest, error)
OpenPullRequest opens a pull request per spec.
func (*Client) PushCommits ¶
func (c *Client) PushCommits(ctx context.Context, repo provider.Repo, branch string, commits []provider.Commit) (string, error)
PushCommits creates each commit in order on branch through the Git Data API and returns the resulting head SHA. No local clone is involved (Phase 0).
func (*Client) ReadRepoFile ¶
func (c *Client) ReadRepoFile(ctx context.Context, repo provider.Repo, ref, path string) (string, error)
ReadRepoFile returns the content of the file at path, at ref (the repo's default branch when ref is empty). Returns ErrNotFound when path does not exist or is a directory.