github

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseRef

func ParseRef(ref, repoHint string) (owner, repo string, number int, err error)

ParseRef parses a reference string into owner, repo, and number Supports formats: - "123" or "#123" (requires repoHint) - "owner/repo#123" - "https://github.com/owner/repo/pull/123" - "https://github.com/owner/repo/issues/123"

func WriteIssueContext

func WriteIssueContext(outputDir string, issueInfo *IssueInfo, comments []IssueComment) ([]collector.FileInfo, error)

WriteIssueContext writes issue context files and returns the list of files written

func WriteManifest

func WriteManifest(outputDir string, result collector.CollectResult) error

WriteManifest writes the collection manifest to the output directory

func WritePRContext

func WritePRContext(outputDir string, prInfo *PRInfo, reviewThreads []ReviewThread, diff string, checkRuns []CheckRun, combinedStatus *CombinedStatus) ([]collector.FileInfo, error)

WritePRContext writes PR context files and returns the list of files written

Types

type CheckRun

type CheckRun struct {
	ID           int64          `json:"id"`
	Name         string         `json:"name"`
	HeadSHA      string         `json:"head_sha"`
	Status       string         `json:"status"`     // queued, in_progress, completed
	Conclusion   string         `json:"conclusion"` // success, failure, neutral, cancelled, skipped, timed_out, action_required
	StartedAt    *time.Time     `json:"started_at,omitempty"`
	CompletedAt  *time.Time     `json:"completed_at,omitempty"`
	DetailsURL   string         `json:"details_url,omitempty"`
	AppSlug      string         `json:"app_slug,omitempty"` // e.g., "github-actions"
	CheckSuiteID int64          `json:"check_suite_id,omitempty"`
	Output       CheckRunOutput `json:"output,omitempty"`
}

CheckRun represents a GitHub check run

type CheckRunOutput

type CheckRunOutput struct {
	Title   string `json:"title,omitempty"`
	Summary string `json:"summary,omitempty"`
	Text    string `json:"text,omitempty"`
}

CheckRunOutput represents the output of a check run

type CheckRunsResponse

type CheckRunsResponse struct {
	TotalCount int        `json:"total_count"`
	CheckRuns  []CheckRun `json:"check_runs"`
}

CheckRunsResponse is the API response for check runs

type Client

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

Client provides methods to fetch GitHub PR and Issue context

func NewClient

func NewClient(token string) *Client

NewClient creates a new GitHub API client

func (*Client) FetchCheckRuns

func (c *Client) FetchCheckRuns(ctx context.Context, owner, repo, ref string, maxResults int) ([]CheckRun, error)

FetchCheckRuns fetches check runs for a commit ref See: https://docs.github.com/en/rest/checks/runs#list-check-runs-for-a-git-reference

func (*Client) FetchCombinedStatus

func (c *Client) FetchCombinedStatus(ctx context.Context, owner, repo, ref string) (*CombinedStatus, error)

FetchCombinedStatus fetches the combined status for a commit ref See: https://docs.github.com/en/rest/commits/statuses#get-the-combined-status-for-a-specific-reference

func (*Client) FetchIssueComments

func (c *Client) FetchIssueComments(ctx context.Context, owner, repo string, issueNumber int) ([]IssueComment, error)

FetchIssueComments fetches comments for an issue

func (*Client) FetchIssueInfo

func (c *Client) FetchIssueInfo(ctx context.Context, owner, repo string, issueNumber int) (*IssueInfo, error)

FetchIssueInfo fetches basic issue information

func (*Client) FetchPRDiff

func (c *Client) FetchPRDiff(ctx context.Context, owner, repo string, prNumber int) (string, error)

FetchPRDiff fetches the unified diff for a PR

func (*Client) FetchPRInfo

func (c *Client) FetchPRInfo(ctx context.Context, owner, repo string, prNumber int) (*PRInfo, error)

FetchPRInfo fetches basic PR information

func (*Client) FetchReviewThreads

func (c *Client) FetchReviewThreads(ctx context.Context, owner, repo string, prNumber int, unresolvedOnly bool) ([]ReviewThread, error)

FetchReviewThreads fetches review comment threads for a PR

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(url string)

SetBaseURL sets the base URL for both the client and the helper (for testing)

type CombinedStatus

type CombinedStatus struct {
	SHA        string   `json:"sha"`
	State      string   `json:"state"` // pending, success, failure, error
	TotalCount int      `json:"total_count"`
	Statuses   []Status `json:"statuses"`
}

CombinedStatus represents the combined status for a ref

type IssueComment

type IssueComment struct {
	CommentID int64     `json:"comment_id"`
	URL       string    `json:"url"`
	Body      string    `json:"body"`
	Author    string    `json:"author"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	IsTrigger bool      `json:"is_trigger,omitempty"` // true if this comment triggered holon
}

IssueComment represents a comment on an issue

type IssueInfo

type IssueInfo struct {
	Number     int       `json:"number"`
	Title      string    `json:"title"`
	Body       string    `json:"body"`
	State      string    `json:"state"`
	URL        string    `json:"url"`
	Author     string    `json:"author"`
	Assignee   string    `json:"assignee,omitempty"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	Repository string    `json:"repository"`
	Labels     []string  `json:"labels,omitempty"`
}

IssueInfo contains basic issue information

type PRInfo

type PRInfo struct {
	Number      int       `json:"number"`
	Title       string    `json:"title"`
	Body        string    `json:"body"`
	State       string    `json:"state"`
	URL         string    `json:"url"`
	BaseRef     string    `json:"base_ref"`
	HeadRef     string    `json:"head_ref"`
	BaseSHA     string    `json:"base_sha"`
	HeadSHA     string    `json:"head_sha"`
	Author      string    `json:"author"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	Repository  string    `json:"repository"`
	MergeCommit string    `json:"merge_commit_sha,omitempty"`
}

PRInfo contains basic pull request information

type Provider

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

Provider implements the collector.Collector interface for GitHub

func NewProvider

func NewProvider() *Provider

NewProvider creates a new GitHub provider

func (*Provider) Collect

Collect gathers context and writes it to the output directory

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name

func (*Provider) Validate

func (p *Provider) Validate(req collector.CollectRequest) error

Validate checks if the request is valid for this provider

type Reply

type Reply struct {
	CommentID   int64     `json:"comment_id"`
	URL         string    `json:"url"`
	Body        string    `json:"body"`
	Author      string    `json:"author"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	InReplyToID int64     `json:"in_reply_to_id"`
	IsTrigger   bool      `json:"is_trigger,omitempty"` // true if this reply triggered holon
}

Reply represents a reply to a review comment

type ReviewThread

type ReviewThread struct {
	CommentID   int64     `json:"comment_id"`
	URL         string    `json:"url"`
	Path        string    `json:"path"`
	Line        int       `json:"line,omitempty"`
	Side        string    `json:"side,omitempty"`
	StartLine   int       `json:"start_line,omitempty"`
	StartSide   string    `json:"start_side,omitempty"`
	DiffHunk    string    `json:"diff_hunk"`
	Body        string    `json:"body"`
	Author      string    `json:"author"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	Resolved    bool      `json:"resolved"`
	InReplyToID int64     `json:"in_reply_to_id,omitempty"`
	Position    int       `json:"position,omitempty"`
	Replies     []Reply   `json:"replies,omitempty"`
	IsTrigger   bool      `json:"is_trigger,omitempty"` // true if this comment triggered holon
}

ReviewThread represents a review comment thread

type Status

type Status struct {
	ID          int64     `json:"id"`
	Context     string    `json:"context"` // e.g., "ci/travis-ci", "coverage/coveralls"
	State       string    `json:"state"`   // pending, success, failure, error
	TargetURL   string    `json:"target_url,omitempty"`
	Description string    `json:"description,omitempty"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

Status represents an individual status

Jump to

Keyboard shortcuts

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