Documentation
¶
Overview ¶
Package github provides GitHub API integration
Index ¶
- Constants
- func FormatEvent(e PREvent) string
- func FormatEventNotification(e Event) string
- 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) 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) 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 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 FormatEventNotification ¶ added in v0.9.0
FormatEventNotification formats an event for display
Types ¶
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) 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) 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
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 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