github

package
v0.22.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Method  string
	Status  int
	Message string
}

APIError represents a non-2xx GitHub response.

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the GitHub REST API.

func NewClient

func NewClient(hc *http.Client, token string, opts ...Option) *Client

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

func (c *Client) ListOrgRepos(ctx context.Context, org string) ([]string, error)

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 Option

type Option func(*Client)

Option configures Client construction.

func WithBaseURL

func WithBaseURL(u string) Option

WithBaseURL overrides the GitHub API base URL.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL