Documentation
¶
Overview ¶
Package github provides GitHub API integration
Index ¶
- Constants
- func FormatCIResult(r CIResult) string
- func FormatEvent(e PREvent) string
- func FormatEventNotification(e Event) string
- type CIResult
- type CIStatus
- type CIWatcher
- func (w *CIWatcher) GetCIStatus(ctx context.Context, prNumber int) (*CIResult, error)
- func (w *CIWatcher) IsWatching(prNumber int) bool
- func (w *CIWatcher) NotifyCh() <-chan CIResult
- func (w *CIWatcher) StopWatching(prNumber int)
- func (w *CIWatcher) WatchPR(ctx context.Context, prNumber int) error
- func (w *CIWatcher) WatchingPRs() []int
- type CIWatcherConfig
- type CheckDetail
- type Client
- func (c *Client) AddLabel(ctx context.Context, number int, label string) error
- func (c *Client) AssignIssue(ctx context.Context, number int, assignees []string) error
- func (c *Client) CloseIssue(ctx context.Context, number int) error
- func (c *Client) CommentIssue(ctx context.Context, number int, body string) error
- func (c *Client) CountOpenIssues(ctx context.Context) (int, error)
- func (c *Client) CreateIssue(ctx context.Context, title, body string, labels []string) (*github.Issue, error)
- func (c *Client) CreatePR(ctx context.Context, title, body, head, base string) (*github.PullRequest, error)
- func (c *Client) EditIssue(ctx context.Context, number int, title, body *string) (*github.Issue, error)
- func (c *Client) GetIssue(ctx context.Context, number int) (*github.Issue, error)
- func (c *Client) GetPR(ctx context.Context, number int) (*github.PullRequest, error)
- func (c *Client) GetPRFiles(ctx context.Context, number int) ([]*github.CommitFile, error)
- func (c *Client) GetPRReviewStatus(ctx context.Context, number int) (PRReviewStatus, error)
- func (c *Client) GetUnderlyingClient() *github.Client
- func (c *Client) HasLabel(ctx context.Context, number int, label string) (bool, error)
- func (c *Client) ListIssueComments(ctx context.Context, number int) ([]*github.IssueComment, error)
- func (c *Client) ListIssueCommentsSince(ctx context.Context, number int, since time.Time) ([]*github.IssueComment, error)
- func (c *Client) ListIssues(ctx context.Context, labels []string) ([]*github.Issue, error)
- func (c *Client) ListIssuesWithOptions(ctx context.Context, state, assignee string, labels []string) ([]*github.Issue, error)
- func (c *Client) ListPRs(ctx context.Context) ([]*github.PullRequest, error)
- func (c *Client) ListPRsAwaitingReview(ctx context.Context) ([]*PRWithReviewStatus, error)
- func (c *Client) MergePR(ctx context.Context, number int, message string) error
- func (c *Client) RemoveLabel(ctx context.Context, number int, label string) error
- func (c *Client) ReviewPR(ctx context.Context, number int, body string, approve bool) error
- type Event
- type EventHandler
- type EventType
- type EventWatcher
- type IssuesEvent
- type PRAction
- type PREvent
- type PRReviewStatus
- type PRWithReviewStatus
- type PullRequestEvent
- type PullRequestReviewEvent
- type Watcher
- type WebhookHandler
Constants ¶
const ( EventIssues = "issues" EventIssueComment = "issue_comment" EventPullRequest = "pull_request" EventPullRequestReview = "pull_request_review" EventPush = "push" )
Event types
Variables ¶
This section is empty.
Functions ¶
func FormatCIResult ¶ added in v0.13.0
FormatCIResult formats a CI result for display
func FormatEventNotification ¶ added in v0.9.0
FormatEventNotification formats an event for display
Types ¶
type CIResult ¶ added in v0.13.0
type CIResult struct {
PRNumber int
PRTitle string
PRURL string
PRAuthor string
Status CIStatus
TotalChecks int
Passed int
Failed int
Pending int
Details []CheckDetail
CompletedAt time.Time
}
CIResult represents the result of CI check monitoring
type CIWatcher ¶ added in v0.13.0
type CIWatcher struct {
// contains filtered or unexported fields
}
CIWatcher monitors CI status for PRs
func NewCIWatcher ¶ added in v0.13.0
func NewCIWatcher(client *Client, config CIWatcherConfig) *CIWatcher
NewCIWatcher creates a new CI watcher
func (*CIWatcher) GetCIStatus ¶ added in v0.13.0
GetCIStatus gets the current CI status for a PR
func (*CIWatcher) IsWatching ¶ added in v0.13.0
IsWatching returns true if the PR is being watched
func (*CIWatcher) StopWatching ¶ added in v0.13.0
StopWatching stops watching a PR
func (*CIWatcher) WatchingPRs ¶ added in v0.13.0
WatchingPRs returns the list of PRs being watched
type CIWatcherConfig ¶ added in v0.13.0
type CIWatcherConfig struct {
// PollInterval is the interval between polling
PollInterval time.Duration
// Timeout is the maximum time to wait for CI completion
Timeout time.Duration
}
CIWatcherConfig holds configuration for CI watcher
func DefaultCIWatcherConfig ¶ added in v0.13.0
func DefaultCIWatcherConfig() CIWatcherConfig
DefaultCIWatcherConfig returns default configuration
type CheckDetail ¶ added in v0.13.0
CheckDetail represents details of a single check
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the GitHub API client
func NewClientWithToken ¶
NewClientWithToken creates a client with explicit token
func (*Client) AssignIssue ¶
AssignIssue assigns an issue to users
func (*Client) CloseIssue ¶
CloseIssue closes an issue
func (*Client) CommentIssue ¶
CommentIssue adds a comment to an issue
func (*Client) CountOpenIssues ¶ added in v0.11.0
CountOpenIssues returns the number of open issues Implements the auto.IssueChecker interface
func (*Client) CreateIssue ¶
func (c *Client) CreateIssue(ctx context.Context, title, body string, labels []string) (*github.Issue, error)
CreateIssue creates a new issue
func (*Client) CreatePR ¶
func (c *Client) CreatePR(ctx context.Context, title, body, head, base string) (*github.PullRequest, error)
CreatePR creates a new pull request
func (*Client) EditIssue ¶ added in v0.10.0
func (c *Client) EditIssue(ctx context.Context, number int, title, body *string) (*github.Issue, error)
EditIssue updates an issue's title and/or body
func (*Client) GetPRFiles ¶
GetPRFiles returns files changed in a PR
func (*Client) GetPRReviewStatus ¶ added in v0.13.0
GetPRReviewStatus returns the current review status of a PR
func (*Client) GetUnderlyingClient ¶ added in v0.12.0
GetUnderlyingClient returns the underlying go-github client
func (*Client) ListIssueComments ¶ added in v0.8.0
ListIssueComments lists comments on an issue
func (*Client) ListIssueCommentsSince ¶ added in v0.8.0
func (c *Client) ListIssueCommentsSince(ctx context.Context, number int, since time.Time) ([]*github.IssueComment, error)
ListIssueCommentsSince lists comments on an issue created after a specific time
func (*Client) ListIssues ¶
ListIssues lists open issues
func (*Client) ListIssuesWithOptions ¶
func (c *Client) ListIssuesWithOptions(ctx context.Context, state, assignee string, labels []string) ([]*github.Issue, error)
ListIssuesWithOptions lists issues with filtering options
func (*Client) ListPRsAwaitingReview ¶ added in v0.13.0
func (c *Client) ListPRsAwaitingReview(ctx context.Context) ([]*PRWithReviewStatus, error)
ListPRsAwaitingReview returns PRs that are waiting for review A PR is considered "awaiting review" if: - It has no reviews yet, OR - It has review_requested status (someone was requested to review) PRs with CHANGES_REQUESTED are NOT included (author needs to fix first)
func (*Client) RemoveLabel ¶ added in v0.8.0
RemoveLabel removes a label from an issue
type Event ¶ added in v0.9.0
type Event struct {
Type EventType
Number int
Title string
Author string
URL string
CreatedAt time.Time
MergedAt time.Time // Only set for EventTypeMergedPR
Labels []string
Body string
}
Event represents a new Issue or PR creation event
type EventHandler ¶
type EventHandler func(payload json.RawMessage) error
EventHandler processes a specific event type
type EventType ¶ added in v0.9.0
type EventType string
EventType represents the type of GitHub event
type EventWatcher ¶ added in v0.9.0
type EventWatcher struct {
// contains filtered or unexported fields
}
EventWatcher monitors new Issue/PR creations
func NewEventWatcher ¶ added in v0.9.0
func NewEventWatcher(client *Client) *EventWatcher
NewEventWatcher creates a new event watcher
func NewEventWatcherWithSince ¶ added in v0.9.0
func NewEventWatcherWithSince(client *Client, since time.Time) *EventWatcher
NewEventWatcherWithSince creates an event watcher with custom start time
func (*EventWatcher) CheckEvents ¶ added in v0.9.0
func (w *EventWatcher) CheckEvents(ctx context.Context) ([]Event, error)
CheckEvents fetches new Issue/PR events since last check
func (*EventWatcher) MarkAsSeen ¶ added in v0.9.0
func (w *EventWatcher) MarkAsSeen(eventType EventType, number int)
MarkAsSeen marks an event as seen (useful for initialization)
func (*EventWatcher) Reset ¶ added in v0.9.0
func (w *EventWatcher) Reset()
Reset clears all seen IDs and resets lastCheck
type IssuesEvent ¶
type IssuesEvent struct {
Action string `json:"action"`
Issue struct {
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"`
User struct {
Login string `json:"login"`
} `json:"user"`
Labels []struct {
Name string `json:"name"`
} `json:"labels"`
Assignees []struct {
Login string `json:"login"`
} `json:"assignees"`
} `json:"issue"`
Repository struct {
FullName string `json:"full_name"`
} `json:"repository"`
}
IssuesEvent represents an issues event payload
func ParseIssuesEvent ¶
func ParseIssuesEvent(payload json.RawMessage) (*IssuesEvent, error)
ParseIssuesEvent parses an issues event
type PREvent ¶
type PREvent struct {
Number int
Title string
Author string
Action PRAction
MergedAt *time.Time
ClosedAt *time.Time
URL string
MergedBy string
CreatedAt time.Time
HeadBranch string // source branch name (e.g., "feature/xxx")
}
PREvent represents a PR event (merge or close)
type PRReviewStatus ¶ added in v0.13.0
type PRReviewStatus string
PRReviewStatus represents the review status of a pull request
const ( // PRReviewStatusPending means no reviews yet or review requested PRReviewStatusPending PRReviewStatus = "PENDING" // PRReviewStatusApproved means the PR has been approved PRReviewStatusApproved PRReviewStatus = "APPROVED" // PRReviewStatusChangesRequested means changes have been requested PRReviewStatusChangesRequested PRReviewStatus = "CHANGES_REQUESTED" )
type PRWithReviewStatus ¶ added in v0.13.0
type PRWithReviewStatus struct {
PR *github.PullRequest
ReviewStatus PRReviewStatus
}
PRWithReviewStatus contains a PR and its review status
type PullRequestEvent ¶
type PullRequestEvent struct {
Action string `json:"action"`
Number int `json:"number"`
PullRequest struct {
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"`
Head struct {
Ref string `json:"ref"`
SHA string `json:"sha"`
} `json:"head"`
Base struct {
Ref string `json:"ref"`
} `json:"base"`
User struct {
Login string `json:"login"`
} `json:"user"`
} `json:"pull_request"`
Repository struct {
FullName string `json:"full_name"`
} `json:"repository"`
}
PullRequestEvent represents a pull_request event payload
func ParsePullRequestEvent ¶
func ParsePullRequestEvent(payload json.RawMessage) (*PullRequestEvent, error)
ParsePullRequestEvent parses a pull_request event
type PullRequestReviewEvent ¶
type PullRequestReviewEvent struct {
Action string `json:"action"`
Review struct {
State string `json:"state"`
Body string `json:"body"`
User struct {
Login string `json:"login"`
} `json:"user"`
} `json:"review"`
PullRequest struct {
Number int `json:"number"`
Title string `json:"title"`
} `json:"pull_request"`
Repository struct {
FullName string `json:"full_name"`
} `json:"repository"`
}
PullRequestReviewEvent represents a pull_request_review event
func ParsePullRequestReviewEvent ¶
func ParsePullRequestReviewEvent(payload json.RawMessage) (*PullRequestReviewEvent, error)
ParsePullRequestReviewEvent parses a pull_request_review event
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher monitors PR events
func NewWatcher ¶
NewWatcher creates a new PR event watcher
func NewWatcherWithSince ¶
NewWatcherWithSince creates a watcher with custom start time
func (*Watcher) CheckEvents ¶
CheckEvents fetches recent PR events since last check
type WebhookHandler ¶
type WebhookHandler struct {
// contains filtered or unexported fields
}
WebhookHandler handles GitHub webhook events
func NewWebhookHandler ¶
func NewWebhookHandler(secret string) *WebhookHandler
NewWebhookHandler creates a new webhook handler
func (*WebhookHandler) On ¶
func (h *WebhookHandler) On(event string, handler EventHandler)
On registers a handler for an event type
func (*WebhookHandler) ServeHTTP ¶
func (h *WebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler