Documentation
¶
Overview ¶
Package github provides typed GitHub REST and GraphQL access via the go-gh library. Credentials resolve through go-gh's auth chain (GH_TOKEN/GITHUB_TOKEN, hosts.yml, then the gh binary's keyring); no gh CLI stdout is ever parsed.
Index ¶
- Constants
- func OverrideForTest(baseURL, token string) (restore func())
- type Client
- func (c *Client) ClosePR(owner, repo string, number int) error
- func (c *Client) CreateIssueComment(owner, repo string, number int, body string) error
- func (c *Client) CreatePR(p CreatePRParams) (string, error)
- func (c *Client) GetPR(owner, repo string, number int) (PRInfo, error)
- func (c *Client) ListIssueComments(owner, repo string, number int) ([]PRComment, error)
- func (c *Client) ListPRReviewComments(owner, repo string, number int) ([]PRComment, error)
- func (c *Client) ListPRReviews(owner, repo string, number int) ([]PRReview, error)
- func (c *Client) ReplyToReviewComment(owner, repo string, number, commentID int, body string) error
- func (c *Client) ResolveReviewThread(threadNodeID string) error
- func (c *Client) ReviewThreadMap(owner, repo string, number int) (map[int]string, error)
- func (c *Client) UpdatePRBody(owner, repo string, number int, body string) error
- type CreatePRParams
- type NoCredentialsError
- type PRComment
- type PRInfo
- type PRReview
Constants ¶
const EnvGitHubAPIBase = "AGENTICO_GITHUB_API_BASE"
EnvGitHubAPIBase is the environment variable that, when set, routes every GitHub API request to the given base URL with a dummy token, bypassing credential resolution. This is the seam packaged e2e journeys use to serve fixture responses from a local HTTP server without needing real gh credentials or a gh binary on PATH.
Variables ¶
This section is empty.
Functions ¶
func OverrideForTest ¶
func OverrideForTest(baseURL, token string) (restore func())
OverrideForTest routes every subsequent client at the given base URL with the given token, bypassing credential resolution and the cache. The returned func undoes the override.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client bundles the REST and GraphQL clients for one GitHub host.
func ForHost ¶
ForHost returns a client for the given GitHub host ("" means github.com). Clients are cached per host.
func (*Client) CreateIssueComment ¶
CreateIssueComment posts a top-level conversation comment on a PR.
func (*Client) CreatePR ¶
func (c *Client) CreatePR(p CreatePRParams) (string, error)
CreatePR opens a pull request and returns its URL. An empty Base targets the repository's default branch. If GitHub answers 422 with "already exists", the existing open PR's URL is returned instead (the branch push that preceded the call already updated it).
func (*Client) GetPR ¶
GetPR returns body, base branch, canonical URL, and open/closed/merged state of a PR.
func (*Client) ListIssueComments ¶
ListIssueComments returns all conversation comments on a PR.
func (*Client) ListPRReviewComments ¶
ListPRReviewComments returns all inline review comments on a PR.
func (*Client) ListPRReviews ¶
ListPRReviews returns all submitted reviews on a PR.
func (*Client) ReplyToReviewComment ¶
ReplyToReviewComment replies in-thread to an inline review comment.
func (*Client) ResolveReviewThread ¶
ResolveReviewThread marks one review thread resolved.
func (*Client) ReviewThreadMap ¶
ReviewThreadMap returns comment-database-ID → thread node ID for every unresolved review thread on a PR (first 100 threads).
type CreatePRParams ¶
CreatePRParams describes a pull request to open.
type NoCredentialsError ¶
type NoCredentialsError struct{ Host string }
NoCredentialsError reports that no token could be resolved for a host.
func (*NoCredentialsError) Error ¶
func (e *NoCredentialsError) Error() string
type PRComment ¶
type PRComment struct {
ID int `json:"id"`
Path string `json:"path"`
Line int `json:"line"`
Body string `json:"body"`
User struct {
Login string `json:"login"`
} `json:"user"`
CreatedAt string `json:"created_at"`
DiffHunk string `json:"diff_hunk"`
InReplyTo int `json:"in_reply_to_id"`
}
PRComment is one inline review comment or issue comment as returned by the GitHub REST API (subset of fields the orchestrator consumes).
type PRInfo ¶
type PRInfo struct {
Body string
BaseRef string
URL string
// State is GitHub's "open" or "closed". A merged PR reports "closed", so
// Merged is what distinguishes the two terminal outcomes.
State string
Merged bool
}
PRInfo is the subset of pull-request details the orchestrator consumes.