github

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListAllIssues

func ListAllIssues(ctx context.Context, client *github.Client, owner, repo string) ([]*github.Issue, error)

ListAllIssues fetches all issues from a repository with pagination This includes both issues and pull requests (GitHub API returns both)

func ListAllPullRequests

func ListAllPullRequests(ctx context.Context, client *github.Client, owner, repo string) ([]*github.PullRequest, error)

ListAllPullRequests fetches all pull requests from a repository with pagination

func NewClient

func NewClient(token string) *github.Client

NewClient creates a GitHub API client with authentication If token is empty, attempts to load from GITHUB_TOKEN environment variable

func ParseBodyReferences

func ParseBodyReferences(body string) []int

ParseBodyReferences extracts issue/PR references from body text Looks for patterns like "Fixes #123", "Closes #456", etc.

Types

type Comment

type Comment struct {
	ID        int64      `json:"id"`
	Author    string     `json:"author"`
	Body      string     `json:"body"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	Reactions *Reactions `json:"reactions,omitempty"`
	URL       string     `json:"url"`
	HTMLURL   string     `json:"html_url"`
}

Comment represents a comment on an issue or PR

func ParseComment

func ParseComment(ghComment *github.IssueComment) Comment

ParseComment converts a go-github IssueComment to our Comment struct

func ParseIssueComments

func ParseIssueComments(ctx context.Context, client *github.Client, owner, repo string, number int) ([]Comment, error)

ParseIssueComments fetches all comments for an issue/PR with pagination

type CrossRef

type CrossRef struct {
	Type      string    `json:"type"`
	Number    int       `json:"number"`
	Title     string    `json:"title"`
	State     string    `json:"state"`
	URL       string    `json:"url"`
	CreatedAt time.Time `json:"created_at"`
}

CrossRef represents a cross-reference between issues/PRs Extracted from timeline for easier access

type Issue

type Issue struct {
	ID              int64           `json:"id"`
	Number          int             `json:"number"`
	Title           string          `json:"title"`
	Body            string          `json:"body"`
	State           string          `json:"state"`
	Author          string          `json:"author"`
	CreatedAt       time.Time       `json:"created_at"`
	UpdatedAt       time.Time       `json:"updated_at"`
	ClosedAt        *time.Time      `json:"closed_at,omitempty"`
	Labels          []string        `json:"labels"`
	Assignees       []string        `json:"assignees"`
	Milestone       *Milestone      `json:"milestone,omitempty"`
	Comments        []Comment       `json:"comments"`
	Timeline        []TimelineEvent `json:"timeline"`
	Reactions       *Reactions      `json:"reactions,omitempty"`
	URL             string          `json:"url"`
	HTMLURL         string          `json:"html_url"`
	CommentCount    int             `json:"comment_count"`
	CrossReferences []CrossRef      `json:"cross_references"`
}

Issue represents GitHub issue data with discussions Optimized for narrative generation with full discussion context

func GetIssue

func GetIssue(ctx context.Context, client *github.Client, owner, repo string, number int) (*Issue, error)

GetIssue fetches a GitHub issue with all comments and timeline

func GetIssuesByAuthor

func GetIssuesByAuthor(issues []Issue, author string) []Issue

GetIssuesByAuthor filters issues by author

func GetIssuesByLabel

func GetIssuesByLabel(issues []Issue, label string) []Issue

GetIssuesByLabel filters issues by label

func ParseIssue

func ParseIssue(ghIssue *github.Issue) *Issue

ParseIssue converts a go-github Issue to our Issue struct

type Milestone

type Milestone struct {
	ID          int64      `json:"id"`
	Number      int        `json:"number"`
	Title       string     `json:"title"`
	Description string     `json:"description"`
	State       string     `json:"state"`
	CreatedAt   time.Time  `json:"created_at"`
	DueOn       *time.Time `json:"due_on,omitempty"`
}

Milestone represents a GitHub milestone

func ParseMilestone

func ParseMilestone(ghMilestone *github.Milestone) *Milestone

ParseMilestone converts a go-github Milestone to our Milestone struct

type PullRequest

type PullRequest struct {
	ID                  int64           `json:"id"`
	Number              int             `json:"number"`
	Title               string          `json:"title"`
	Description         string          `json:"description"`
	State               string          `json:"state"`
	Author              string          `json:"author"`
	CreatedAt           time.Time       `json:"created_at"`
	UpdatedAt           time.Time       `json:"updated_at"`
	MergedAt            *time.Time      `json:"merged_at,omitempty"`
	ClosedAt            *time.Time      `json:"closed_at,omitempty"`
	Labels              []string        `json:"labels"`
	Assignees           []string        `json:"assignees"`
	RequestedReviewers  []string        `json:"requested_reviewers"`
	Milestone           *Milestone      `json:"milestone,omitempty"`
	Comments            []Comment       `json:"comments"`
	ReviewComments      []ReviewComment `json:"review_comments"`
	Reviews             []Review        `json:"reviews"`
	Timeline            []TimelineEvent `json:"timeline"`
	BaseBranch          string          `json:"base_branch"`
	HeadBranch          string          `json:"head_branch"`
	Merged              bool            `json:"merged"`
	Mergeable           bool            `json:"mergeable"`
	Draft               bool            `json:"draft"`
	Additions           int             `json:"additions"`
	Deletions           int             `json:"deletions"`
	ChangedFiles        int             `json:"changed_files"`
	MergeCommitSHA      string          `json:"merge_commit_sha,omitempty"`
	MaintainerCanModify bool            `json:"maintainer_can_modify"`
	URL                 string          `json:"url"`
	HTMLURL             string          `json:"html_url"`
	CrossReferences     []CrossRef      `json:"cross_references"`
}

PullRequest represents GitHub pull request data with discussions Designed to capture complete code review context

func GetPRsByAuthor

func GetPRsByAuthor(prs []PullRequest, author string) []PullRequest

GetPRsByAuthor filters pull requests by author

func GetPullRequest

func GetPullRequest(ctx context.Context, client *github.Client, owner, repo string, number int) (*PullRequest, error)

GetPullRequest fetches a GitHub pull request with all discussions

func ParsePullRequest

func ParsePullRequest(ghPR *github.PullRequest) *PullRequest

ParsePullRequest converts a go-github PullRequest to our PullRequest struct

type Reactions

type Reactions struct {
	TotalCount int `json:"total_count"`
	PlusOne    int `json:"plus_one"`
	MinusOne   int `json:"minus_one"`
	Laugh      int `json:"laugh"`
	Confused   int `json:"confused"`
	Heart      int `json:"heart"`
	Hooray     int `json:"hooray"`
	Rocket     int `json:"rocket"`
	Eyes       int `json:"eyes"`
}

Reactions represents GitHub reactions to content

func ParseReactions

func ParseReactions(ghReactions *github.Reactions) *Reactions

ParseReactions converts go-github Reactions to our Reactions struct

type Review

type Review struct {
	ID          int64     `json:"id"`
	Author      string    `json:"author"`
	Body        string    `json:"body"`
	State       string    `json:"state"`
	SubmittedAt time.Time `json:"submitted_at"`
	URL         string    `json:"url"`
}

Review represents a PR review

func ParseReview

func ParseReview(ghReview *github.PullRequestReview) Review

ParseReview converts a go-github PullRequestReview to our Review struct

func ParseReviews

func ParseReviews(ctx context.Context, client *github.Client, owner, repo string, number int) ([]Review, error)

ParseReviews fetches all reviews for a PR with pagination

type ReviewComment

type ReviewComment struct {
	ID                int64      `json:"id"`
	Author            string     `json:"author"`
	Body              string     `json:"body"`
	Path              string     `json:"path"`
	Line              int        `json:"line,omitempty"`
	StartLine         int        `json:"start_line,omitempty"`
	Side              string     `json:"side,omitempty"`
	StartSide         string     `json:"start_side,omitempty"`
	OriginalLine      int        `json:"original_line,omitempty"`
	OriginalStartLine int        `json:"original_start_line,omitempty"`
	InReplyToID       int64      `json:"in_reply_to_id,omitempty"`
	CommitID          string     `json:"commit_id"`
	OriginalCommitID  string     `json:"original_commit_id"`
	SubjectType       string     `json:"subject_type,omitempty"`
	DiffHunk          string     `json:"diff_hunk,omitempty"`
	CreatedAt         time.Time  `json:"created_at"`
	UpdatedAt         time.Time  `json:"updated_at"`
	Reactions         *Reactions `json:"reactions,omitempty"`
	URL               string     `json:"url"`
	HTMLURL           string     `json:"html_url"`
}

ReviewComment represents a code review comment on a PR Includes threading and location metadata for context reconstruction

func ParseReviewComment

func ParseReviewComment(ghComment *github.PullRequestComment) ReviewComment

ParseReviewComment converts a go-github PullRequestComment to our ReviewComment struct

func ParseReviewComments

func ParseReviewComments(ctx context.Context, client *github.Client, owner, repo string, number int) ([]ReviewComment, error)

ParseReviewComments fetches all review comments for a PR with pagination

type TimelineEvent

type TimelineEvent struct {
	Event     string          `json:"event"`
	Actor     string          `json:"actor"`
	CreatedAt time.Time       `json:"created_at"`
	Source    *TimelineSource `json:"source,omitempty"`
}

TimelineEvent represents an event in the issue/PR timeline

func ParseTimeline

func ParseTimeline(ctx context.Context, client *github.Client, owner, repo string, number int) ([]TimelineEvent, error)

ParseTimeline fetches timeline events for cross-references

func ParseTimelineEvent

func ParseTimelineEvent(ghEvent *github.Timeline) TimelineEvent

ParseTimelineEvent converts a go-github Timeline to our TimelineEvent struct

type TimelineSource

type TimelineSource struct {
	Type   string `json:"type"`
	Number int    `json:"number"`
	Title  string `json:"title"`
	State  string `json:"state"`
	URL    string `json:"url"`
}

TimelineSource represents the source of a cross-reference

Jump to

Keyboard shortcuts

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