Documentation
¶
Overview ¶
Package github is a minimal GitHub API client covering only the endpoints notifycat needs for validation. It is intentionally narrow — adding a new endpoint means adding one method, not pulling in go-github.
Index ¶
- type APIError
- type Client
- func (c *Client) GetPullRequest(ctx context.Context, owner, repo string, number int) (PullRequestState, error)
- func (c *Client) ListHookEvents(ctx context.Context, owner, repo, urlSuffix string) ([]string, error)
- func (c *Client) ListOrgRepos(ctx context.Context, org string) ([]string, error)
- func (c *Client) ListPullRequestFiles(ctx context.Context, owner, repo string, number int) ([]string, error)
- type Hook
- type Option
- type PullRequestState
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 talks to the GitHub REST API.
func NewClient ¶
NewClient builds a Client. The httpClient is used as-is; callers should configure timeouts on it.
func (*Client) GetPullRequest ¶
func (c *Client) GetPullRequest(ctx context.Context, owner, repo string, number int) (PullRequestState, error)
GetPullRequest fetches a single PR's open/closed and draft state. A non-2xx response is returned as a typed *APIError (e.g. Status 404 for a missing or inaccessible PR) so callers can decide how to treat it.
func (*Client) ListHookEvents ¶
func (c *Client) ListHookEvents(ctx context.Context, owner, repo, urlSuffix string) ([]string, error)
ListHookEvents returns the union of events configured across active hooks pointing at notifycat (matched by `urlSuffix` against hook.config.url). Returns an empty slice when no matching hook exists, so callers can distinguish "no notifycat hook" from "hook misconfigured".
func (*Client) ListOrgRepos ¶
ListOrgRepos returns the names of every repository in the org, following GitHub's Link header for pagination. Empty result is a normal outcome (org with no repos or all repos filtered by token scope).
func (*Client) ListPullRequestFiles ¶
func (c *Client) ListPullRequestFiles(ctx context.Context, owner, repo string, number int) ([]string, error)
ListPullRequestFiles returns the repo-relative paths of every file changed in a PR, following GitHub's Link header for pagination. Path routing uses it to decide which directory rules a PR touches. An empty result is possible (a PR with no file changes).
type Hook ¶
type Hook struct {
ID int64 `json:"id"`
Active bool `json:"active"`
Events []string `json:"events"`
Config struct {
URL string `json:"url"`
} `json:"config"`
}
Hook is the subset of a repository webhook record we care about.
type PullRequestState ¶
type PullRequestState struct {
State string `json:"state"` // "open" | "closed"
Draft bool `json:"draft"`
}
PullRequestState is the subset of a PR's status the stuck-PR digest needs to decide whether the PR is still worth nagging about.