Help us shape the future of Go! Take the 2026 Go Developer Survey

github

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoToken = errors.New("no GitHub token available")
View Source
var ErrRateLimited = errors.New("GitHub rate limit exceeded")
View Source
var ErrReadinessHeadChanged = errors.New("pull request head changed while reading readiness")
View Source
var ErrSelfRateLimited = errors.New("self-imposed rate limit exceeded")

Functions

func CIStatusFromMergeableState added in v0.12.0

func CIStatusFromMergeableState(mergeableState string) string

func CheckGHVersion

func CheckGHVersion() (string, error)

func FetchPullRequestFeedback added in v0.12.0

func FetchPullRequestFeedback(ctx context.Context, transport QueryTransport, repo string, number int) ([]prreadiness.FeedbackItem, []prreadiness.ThreadState, error)

func FetchPullRequestReadiness added in v0.12.0

func FetchPullRequestReadiness(ctx context.Context, transport QueryTransport, repo string, number int) (*prreadiness.Observation, error)

func GetTokenForHost

func GetTokenForHost(ctx context.Context, host string) (string, error)

func GitHTTPSAuthorizationHeader added in v0.12.0

func GitHTTPSAuthorizationHeader(token string) string

func InstallHint added in v0.12.0

func InstallHint() string

func RequireGHVersion

func RequireGHVersion(minVersion string) error

func UpgradeHint added in v0.12.0

func UpgradeHint() string

Types

type Client

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

func NewClient

func NewClient(baseURL, token string) (*Client, error)

func NewClientForHost

func NewClientForHost(host, apiURL, token string) (*Client, error)

func (*Client) ApprovePR

func (c *Client) ApprovePR(repo string, number int) error

func (*Client) FetchAll

func (c *Client) FetchAll() ([]*protocol.PR, error)

func (*Client) FetchPRDetails

func (c *Client) FetchPRDetails(repo string, number int) (*PRDetails, error)

func (*Client) FetchPRState added in v0.12.0

func (c *Client) FetchPRState(ctx context.Context, repo string, number int) (state string, merged bool, title string, err error)

func (*Client) FetchPullRequestFeedback added in v0.12.0

func (c *Client) FetchPullRequestFeedback(ctx context.Context, repo string, number int) ([]prreadiness.FeedbackItem, []prreadiness.ThreadState, error)

func (*Client) FetchPullRequestReadiness added in v0.12.0

func (c *Client) FetchPullRequestReadiness(ctx context.Context, repo string, number int) (*prreadiness.Observation, error)

func (*Client) FetchPullRequestReviewStatus added in v0.12.0

func (c *Client) FetchPullRequestReviewStatus(repo string, number int) (string, error)

func (*Client) FetchPullRequestSnapshot added in v0.12.0

func (c *Client) FetchPullRequestSnapshot(repo string, number int) (*PullRequestSnapshot, error)

func (*Client) GetRateLimit

func (c *Client) GetRateLimit(resource string) *RateLimitInfo

func (*Client) GitHTTPSAuthorizationHeader added in v0.12.0

func (c *Client) GitHTTPSAuthorizationHeader() string

func (*Client) GraphQL added in v0.12.0

func (c *Client) GraphQL(ctx context.Context, query string, variables map[string]any) ([]byte, error)

func (*Client) Host

func (c *Client) Host() string

func (*Client) IsAvailable

func (c *Client) IsAvailable() bool

func (*Client) IsRateLimited

func (c *Client) IsRateLimited(resource string) (bool, time.Time)

func (*Client) ListMergedPullRequests added in v0.12.0

func (c *Client) ListMergedPullRequests(repo string) ([]MergedPullRequest, error)

func (*Client) ListMergedPullRequestsContext added in v0.12.0

func (c *Client) ListMergedPullRequestsContext(ctx context.Context, repo string) ([]MergedPullRequest, error)

func (*Client) MergePR

func (c *Client) MergePR(repo string, number int, method string) error

func (*Client) RepoVisibility added in v0.12.0

func (c *Client) RepoVisibility(repo string) (string, error)

func (*Client) SearchAuthoredPRs

func (c *Client) SearchAuthoredPRs() ([]*protocol.PR, error)

func (*Client) SearchReviewRequestedPRs

func (c *Client) SearchReviewRequestedPRs() ([]*protocol.PR, error)

func (*Client) SearchReviewedByMePRs

func (c *Client) SearchReviewedByMePRs() ([]*protocol.PR, error)

type ClientRegistry

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

func NewClientRegistry

func NewClientRegistry() *ClientRegistry

func (*ClientRegistry) FetchAllPRs

func (r *ClientRegistry) FetchAllPRs() ([]*protocol.PR, error)

func (*ClientRegistry) Get

func (r *ClientRegistry) Get(host string) (*Client, bool)

func (*ClientRegistry) Hosts

func (r *ClientRegistry) Hosts() []string

func (*ClientRegistry) Register

func (r *ClientRegistry) Register(host string, client *Client)

func (*ClientRegistry) Remove

func (r *ClientRegistry) Remove(host string)

type GitHubClient

type GitHubClient interface {
	Host() string
	IsAvailable() bool
	FetchAll() ([]*protocol.PR, error)
	FetchPRDetails(repo string, number int) (*PRDetails, error)
	ApprovePR(repo string, number int) error
	MergePR(repo string, number int, method string) error
	IsRateLimited(resource string) (bool, time.Time)
	GetRateLimit(resource string) *RateLimitInfo
}

type HostInfo

type HostInfo struct {
	Host   string
	APIURL string
	Login  string
	Active bool
}

func DiscoverHosts

func DiscoverHosts(ctx context.Context) ([]HostInfo, error)

type MergedPullRequest added in v0.12.0

type MergedPullRequest struct {
	Number   int
	URL      string
	HeadRef  string
	HeadSHA  string
	BaseRef  string
	MergedAt string
}

type PRDetails

type PRDetails struct {
	Mergeable      *bool
	MergeableState string
	CIStatus       string
	ReviewStatus   string
	HeadSHA        string
	HeadBranch     string
}

type PullRequestSnapshot added in v0.12.0

type PullRequestSnapshot struct {
	Number         int
	URL            string
	Title          string
	Body           string
	Author         string
	Draft          bool
	State          string
	Merged         bool
	Mergeable      *bool
	MergeableState string
	HeadSHA        string
	HeadRef        string
	HeadRepository string
	BaseSHA        string
	BaseRef        string
	BaseRepository string
}

type QueryTransport added in v0.12.0

type QueryTransport interface {
	GraphQL(context.Context, string, map[string]any) ([]byte, error)
}

type RateLimitInfo

type RateLimitInfo struct {
	Resource  string
	Remaining int
	ResetAt   time.Time
}

type VersionTooOldError added in v0.12.0

type VersionTooOldError struct {
	Have string
	Want string
}

func (*VersionTooOldError) Error added in v0.12.0

func (e *VersionTooOldError) Error() string

Directories

Path Synopsis
Package githubschema checks GraphQL queries against GitHub's public schema, refreshed from https://docs.github.com/public/fpt/schema.docs.graphql.
Package githubschema checks GraphQL queries against GitHub's public schema, refreshed from https://docs.github.com/public/fpt/schema.docs.graphql.

Jump to

Keyboard shortcuts

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