Documentation
¶
Index ¶
- Variables
- func ParseGitHubRemote(remoteURL string) (owner, repo string, ok bool)
- type Client
- func (c *Client) ListIssueComments(ctx context.Context, owner, repo string, number int) ([]Comment, error)
- func (c *Client) ListIssues(ctx context.Context, owner, repo string, opts ListIssuesOptions) ([]Issue, *RateLimit, error)
- func (c *Client) ListPRComments(ctx context.Context, owner, repo string, number int) ([]Comment, error)
- func (c *Client) ListPullRequests(ctx context.Context, owner, repo string, opts ListPRsOptions) ([]PullRequest, *RateLimit, error)
- type Comment
- type Fetcher
- func (f *Fetcher) ListIssueComments(ctx context.Context, owner, repo string, number int) ([]ledger.FetchedComment, error)
- func (f *Fetcher) ListIssues(ctx context.Context, owner, repo string, opts ledger.ListIssuesOptions) ([]ledger.FetchedIssue, *ledger.FetchRateLimit, error)
- func (f *Fetcher) ListPRComments(ctx context.Context, owner, repo string, number int) ([]ledger.FetchedComment, error)
- func (f *Fetcher) ListPullRequests(ctx context.Context, owner, repo string, opts ledger.ListPRsOptions) ([]ledger.FetchedPR, *ledger.FetchRateLimit, error)
- type GitHubUser
- type Issue
- type Label
- type ListIssuesOptions
- type ListPRsOptions
- type PullRequest
- type RateLimit
Constants ¶
This section is empty.
Variables ¶
var ErrGitHubAuth = errors.New("github authentication failed")
ErrGitHubAuth indicates a 401/403 authentication or authorization failure.
var ErrGitHubRateLimited = errors.New("github rate limited")
ErrGitHubRateLimited indicates a 429 rate limit response.
Functions ¶
func ParseGitHubRemote ¶
ParseGitHubRemote extracts owner and repo from a git remote URL. Supports:
- https://github.com/owner/repo.git
- git@github.com:owner/repo.git
- ssh://git@github.com/owner/repo.git
Returns ("", "", false) for non-GitHub URLs.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a minimal GitHub REST API client for fetching PR data.
func (*Client) ListIssueComments ¶
func (c *Client) ListIssueComments(ctx context.Context, owner, repo string, number int) ([]Comment, error)
ListIssueComments fetches all general discussion comments on a pull request.
func (*Client) ListIssues ¶
func (c *Client) ListIssues(ctx context.Context, owner, repo string, opts ListIssuesOptions) ([]Issue, *RateLimit, error)
ListIssues fetches issues for a repository with pagination. Filters out pull requests (GitHub API returns PRs as issues). When opts.Since is set, pagination stops when issues older than Since are encountered (requires Sort="updated", Direction="desc" to work correctly).
func (*Client) ListPRComments ¶
func (c *Client) ListPRComments(ctx context.Context, owner, repo string, number int) ([]Comment, error)
ListPRComments fetches all review comments (file-level) on a pull request.
func (*Client) ListPullRequests ¶
func (c *Client) ListPullRequests(ctx context.Context, owner, repo string, opts ListPRsOptions) ([]PullRequest, *RateLimit, error)
ListPullRequests fetches pull requests for a repository with pagination. When opts.Since is set, pagination stops when PRs older than Since are encountered (requires Sort="updated", Direction="desc" to work correctly).
type Comment ¶
type Comment struct {
ID int64 `json:"id"`
User GitHubUser `json:"user"`
Body string `json:"body"`
Path string `json:"path,omitempty"`
Line *int `json:"line,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
Comment represents either a PR review comment or an issue comment. Path and Line are only populated for review comments (file-level).
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher wraps a Client to satisfy ledger.GitHubFetcher.
func NewFetcher ¶
NewFetcher creates a GitHubFetcher from a Client.
func (*Fetcher) ListIssueComments ¶
func (*Fetcher) ListIssues ¶
func (f *Fetcher) ListIssues(ctx context.Context, owner, repo string, opts ledger.ListIssuesOptions) ([]ledger.FetchedIssue, *ledger.FetchRateLimit, error)
func (*Fetcher) ListPRComments ¶
func (*Fetcher) ListPullRequests ¶
type GitHubUser ¶
type GitHubUser struct {
Login string `json:"login"`
}
GitHubUser is a minimal GitHub user reference.
type Issue ¶
type Issue struct {
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"` // open, closed
User GitHubUser `json:"user"`
Labels []Label `json:"labels"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ClosedAt *time.Time `json:"closed_at"`
HTMLURL string `json:"html_url"`
// PullRequest is non-nil when this "issue" is actually a PR.
// Used to filter out PRs from issue listings.
PullRequest *struct{} `json:"pull_request,omitempty"`
}
Issue represents a GitHub issue from the REST API. Note: GitHub's API returns PRs as issues too — filter by checking whether the "pull_request" field is present (excluded in our struct).
type ListIssuesOptions ¶
type ListIssuesOptions struct {
State string // "all", "open", "closed" (default: "all")
Sort string // "updated" (default)
Direction string // "desc" (default)
Since time.Time // stop pagination when issues are older than this
PerPage int // max 100 (default: 100)
Page int // starting page (default: 1)
}
ListIssuesOptions controls pagination and filtering for ListIssues.
type ListPRsOptions ¶
type ListPRsOptions struct {
State string // "all", "open", "closed" (default: "all")
Sort string // "updated" (default)
Direction string // "desc" (default)
Since time.Time // stop pagination when PRs are older than this
PerPage int // max 100 (default: 100)
Page int // starting page (default: 1)
}
ListPRsOptions controls pagination and filtering for ListPullRequests.
type PullRequest ¶
type PullRequest struct {
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"` // open, closed
User GitHubUser `json:"user"`
Labels []Label `json:"labels"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
MergedAt *time.Time `json:"merged_at"`
MergeSHA string `json:"merge_commit_sha"`
HTMLURL string `json:"html_url"`
Draft bool `json:"draft"`
}
PullRequest represents a GitHub pull request from the REST API.