Documentation
¶
Overview ¶
Package github provides a GitHub API client for GitHub App interactions.
Index ¶
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 wraps the GitHub API client.
func (*Client) FindPRsForCommit ¶
FindPRsForCommit finds all open PRs associated with a commit SHA.
func (*Client) InstallationToken ¶
InstallationToken returns the current installation token, refreshing if needed. This method is safe to call concurrently - only one goroutine will perform the refresh.
func (*Client) Organization ¶
Organization returns the organization associated with this installation.
type ClientInterface ¶
type ClientInterface interface {
// Client returns the underlying go-github client for advanced operations.
Client() any
// InstallationToken returns the current installation token for authentication.
InstallationToken(ctx context.Context) string
}
ClientInterface defines the interface for GitHub API operations. This interface enables testing of code that depends on Client.
type GraphQLClient ¶
type GraphQLClient = SearchClient
GraphQLClient is a deprecated alias for SearchClient for backwards compatibility. Use SearchClient instead.
func NewGraphQLClient ¶
func NewGraphQLClient(ctx context.Context, token string) *GraphQLClient
NewGraphQLClient creates a new search client (deprecated name). Use NewSearchClient instead.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages multiple GitHub App installations.
func NewManager ¶
func NewManager(ctx context.Context, appID, privateKeyPEM string, allowPersonalAccounts bool) (*Manager, error)
NewManager creates a new installation manager.
func (*Manager) ClientForOrg ¶
ClientForOrg returns the GitHub client for a specific organization.
type ManagerInterface ¶
type ManagerInterface interface {
// AllOrgs returns all configured organizations.
AllOrgs() []string
// ClientForOrg returns the GitHub client for a specific organization.
ClientForOrg(org string) (ClientInterface, bool)
}
ManagerInterface defines the interface for GitHub installation management. This interface enables testing of code that depends on Manager.
func WrapManager ¶
func WrapManager(m *Manager) ManagerInterface
WrapManager wraps a Manager to implement ManagerInterface. This is needed because Manager.ClientForOrg returns *Client, but ManagerInterface.ClientForOrg must return ClientInterface.
type PRInfo ¶
type PRInfo struct {
CreatedAt time.Time
UpdatedAt time.Time
Owner string
Repo string
Title string
Author string
State string
URL string
BlockedOn []string
Number int
}
PRInfo contains simplified PR information.
type PRSnapshot ¶
type PRSnapshot struct {
UpdatedAt time.Time
CreatedAt time.Time
Owner string
Repo string
Title string
Author string
URL string
State string // "OPEN", "CLOSED", "MERGED"
Number int
IsDraft bool
}
PRSnapshot contains minimal PR information from search query.
type SearchClient ¶
type SearchClient struct {
// contains filtered or unexported fields
}
SearchClient wraps the GitHub Search API client for querying PRs.
func NewSearchClient ¶
func NewSearchClient(ctx context.Context, token string) *SearchClient
NewSearchClient creates a new search client with the given token.
func (*SearchClient) ListClosedPRs ¶
func (c *SearchClient) ListClosedPRs(ctx context.Context, org string, updatedSinceHours int) ([]PRSnapshot, error)
ListClosedPRs queries all closed/merged PRs for an organization updated in the last N hours. This is used to update Slack threads when PRs are closed or merged.
func (*SearchClient) ListOpenPRs ¶
func (c *SearchClient) ListOpenPRs(ctx context.Context, org string, updatedSinceHours int) ([]PRSnapshot, error)
ListOpenPRs queries all open PRs for an organization updated in the last N hours. Uses GitHub Search API which is simpler and more reliable than GraphQL.
type TurnClient ¶
type TurnClient interface {
Check(ctx context.Context, prURL, username string, eventTime time.Time) (*turn.CheckResponse, error)
}
TurnClient is an interface for PR analysis.
func NewTurnClient ¶
func NewTurnClient(token string) (TurnClient, error)
NewTurnClient creates a turnclient with the given token.