github

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides methods to interact with GitHub's GraphQL API.

func NewClient

func NewClient() (*Client, error)

NewClient creates a new GitHub client using gh auth.

func (*Client) AddComment

func (c *Client) AddComment(subjectID, body string) error

AddComment adds a new comment to an issue or PR.

func (*Client) AddDiscussionComment

func (c *Client) AddDiscussionComment(discussionID, body string) error

AddDiscussionComment adds a new comment to a discussion.

func (*Client) AddDiscussionCommentReply

func (c *Client) AddDiscussionCommentReply(replyToID, body string) error

AddDiscussionCommentReply adds a reply to a discussion comment.

func (*Client) AddReviewThreadReply

func (c *Client) AddReviewThreadReply(threadID, body string) error

AddReviewThreadReply adds a reply to a PR review thread.

func (*Client) CloseIssue

func (c *Client) CloseIssue(id string) error

CloseIssue closes an issue.

func (*Client) ClosePullRequest

func (c *Client) ClosePullRequest(id string) error

ClosePullRequest closes a pull request.

func (*Client) FetchComments

func (c *Client) FetchComments(itemType ItemType, owner, repo string, number int) ([]RemoteComment, error)

FetchComments fetches current comments for an item.

func (*Client) FetchDiscussion

func (c *Client) FetchDiscussion(owner, repo string, number int) (*Discussion, error)

FetchDiscussion fetches a single discussion by number.

func (*Client) FetchDiscussions

func (c *Client) FetchDiscussions(owner, repo string, limit int) ([]Discussion, error)

FetchDiscussions fetches all discussions from a repository with pagination.

func (*Client) FetchIssue

func (c *Client) FetchIssue(owner, repo string, number int) (*Issue, error)

FetchIssue fetches a single issue by number.

func (*Client) FetchIssues

func (c *Client) FetchIssues(owner, repo string, limit int) ([]Issue, error)

FetchIssues fetches all issues from a repository with pagination.

func (*Client) FetchPullRequest

func (c *Client) FetchPullRequest(owner, repo string, number int) (*PullRequest, error)

FetchPullRequest fetches a single PR by number.

func (*Client) FetchPullRequests

func (c *Client) FetchPullRequests(owner, repo string, limit int) ([]PullRequest, error)

FetchPullRequests fetches all PRs from a repository with pagination.

func (*Client) FetchRemoteState

func (c *Client) FetchRemoteState(itemType ItemType, owner, repo string, number int) (RemoteState, error)

FetchRemoteState fetches the updatedAt timestamp and state for an item.

func (*Client) Query

func (c *Client) Query(query string, variables map[string]interface{}, response interface{}) error

Query executes a GraphQL query.

func (*Client) ReopenIssue

func (c *Client) ReopenIssue(id string) error

ReopenIssue reopens an issue.

func (*Client) ReopenPullRequest

func (c *Client) ReopenPullRequest(id string) error

ReopenPullRequest reopens a pull request.

func (*Client) UpdateDiscussion

func (c *Client) UpdateDiscussion(id, title, body string) error

UpdateDiscussion updates a discussion's title and body.

func (*Client) UpdateDiscussionComment

func (c *Client) UpdateDiscussionComment(commentID, body string) error

UpdateDiscussionComment updates an existing discussion comment.

func (*Client) UpdateIssue

func (c *Client) UpdateIssue(id, title, body string) error

UpdateIssue updates an issue's title and body.

func (*Client) UpdateIssueComment

func (c *Client) UpdateIssueComment(commentID, body string) error

UpdateIssueComment updates an existing comment on an issue or PR.

func (*Client) UpdatePullRequest

func (c *Client) UpdatePullRequest(id, title, body string) error

UpdatePullRequest updates a PR's title and body.

type Comment

type Comment struct {
	ID        string    `json:"id"`
	Author    string    `json:"author"`
	Body      string    `json:"body"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Comment represents a comment on an issue, PR, or discussion.

type Discussion

type Discussion struct {
	ID        string              `json:"id"`
	URL       string              `json:"url"`
	Number    int                 `json:"number"`
	Owner     string              `json:"owner"`
	Repo      string              `json:"repo"`
	Title     string              `json:"title"`
	Body      string              `json:"body"`
	Category  string              `json:"category"`
	Author    string              `json:"author"`
	AnswerID  string              `json:"answerId,omitempty"`
	Locked    bool                `json:"locked"`
	CreatedAt time.Time           `json:"createdAt"`
	UpdatedAt time.Time           `json:"updatedAt"`
	Comments  []DiscussionComment `json:"comments"`
}

Discussion represents a GitHub discussion with all metadata.

type DiscussionComment

type DiscussionComment struct {
	ID        string              `json:"id"`
	Author    string              `json:"author"`
	Body      string              `json:"body"`
	CreatedAt time.Time           `json:"createdAt"`
	UpdatedAt time.Time           `json:"updatedAt"`
	Replies   []DiscussionComment `json:"replies,omitempty"`
}

DiscussionComment represents a comment or reply in a discussion.

type DiscussionCommentNode

type DiscussionCommentNode struct {
	ID        string    `json:"id"`
	Body      string    `json:"body"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	Author    struct {
		Login string `json:"login"`
	} `json:"author"`
	Replies struct {
		Nodes []struct {
			ID        string    `json:"id"`
			Body      string    `json:"body"`
			CreatedAt time.Time `json:"createdAt"`
			UpdatedAt time.Time `json:"updatedAt"`
			Author    struct {
				Login string `json:"login"`
			} `json:"author"`
		} `json:"nodes"`
	} `json:"replies"`
}

DiscussionCommentNode represents a comment in a discussion.

type DiscussionNode

type DiscussionNode struct {
	ID        string    `json:"id"`
	URL       string    `json:"url"`
	Number    int       `json:"number"`
	Title     string    `json:"title"`
	Body      string    `json:"body"`
	Locked    bool      `json:"locked"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	Category  struct {
		Name string `json:"name"`
	} `json:"category"`
	Author struct {
		Login string `json:"login"`
	} `json:"author"`
	Answer struct {
		ID string `json:"id"`
	} `json:"answer"`
	Comments struct {
		Nodes []DiscussionCommentNode `json:"nodes"`
	} `json:"comments"`
}

DiscussionNode represents a discussion in the GraphQL response.

type DiscussionsResponse

type DiscussionsResponse struct {
	Repository struct {
		Discussions struct {
			PageInfo struct {
				HasNextPage bool   `json:"hasNextPage"`
				EndCursor   string `json:"endCursor"`
			} `json:"pageInfo"`
			Nodes []DiscussionNode `json:"nodes"`
		} `json:"discussions"`
	} `json:"repository"`
}

DiscussionsResponse represents the GraphQL response for discussions.

type Issue

type Issue struct {
	ID               string            `json:"id"`
	URL              string            `json:"url"`
	Number           int               `json:"number"`
	Owner            string            `json:"owner"`
	Repo             string            `json:"repo"`
	Title            string            `json:"title"`
	Body             string            `json:"body"`
	State            string            `json:"state"`
	Author           string            `json:"author"`
	Labels           []string          `json:"labels"`
	Assignees        []string          `json:"assignees"`
	CreatedAt        time.Time         `json:"createdAt"`
	UpdatedAt        time.Time         `json:"updatedAt"`
	Comments         []Comment         `json:"comments"`
	Parent           *IssueReference   `json:"parent,omitempty"`
	Children         []IssueReference  `json:"children,omitempty"`
	SubIssuesSummary *SubIssuesSummary `json:"subIssuesSummary,omitempty"`
}

Issue represents a GitHub issue with all metadata.

type IssueNode

type IssueNode struct {
	ID     string `json:"id"`
	URL    string `json:"url"`
	Number int    `json:"number"`
	Title  string `json:"title"`
	Body   string `json:"body"`
	State  string `json:"state"`
	Author struct {
		Login string `json:"login"`
	} `json:"author"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	Labels    struct {
		Nodes []struct {
			Name string `json:"name"`
		} `json:"nodes"`
	} `json:"labels"`
	Assignees struct {
		Nodes []struct {
			Login string `json:"login"`
		} `json:"nodes"`
	} `json:"assignees"`
	Comments struct {
		Nodes []struct {
			ID        string    `json:"id"`
			Body      string    `json:"body"`
			CreatedAt time.Time `json:"createdAt"`
			UpdatedAt time.Time `json:"updatedAt"`
			Author    struct {
				Login string `json:"login"`
			} `json:"author"`
		} `json:"nodes"`
	} `json:"comments"`
	Parent    *ParentIssueNode `json:"parent"`
	SubIssues struct {
		Nodes []SubIssueNode `json:"nodes"`
	} `json:"subIssues"`
	SubIssuesSummary *SubIssuesSummaryNode `json:"subIssuesSummary"`
}

IssueNode represents an issue in the GraphQL response.

type IssueReference

type IssueReference struct {
	ID     string `json:"id"`
	Number int    `json:"number"`
	Title  string `json:"title"`
	URL    string `json:"url"`
	State  string `json:"state"`
	Owner  string `json:"owner"`
	Repo   string `json:"repo"`
}

IssueReference represents a reference to a parent or child issue.

type IssuesResponse

type IssuesResponse struct {
	Repository struct {
		Issues struct {
			PageInfo struct {
				HasNextPage bool   `json:"hasNextPage"`
				EndCursor   string `json:"endCursor"`
			} `json:"pageInfo"`
			Nodes []IssueNode `json:"nodes"`
		} `json:"issues"`
	} `json:"repository"`
}

IssuesResponse represents the GraphQL response for issues.

type ItemType

type ItemType string

ItemType represents the type of GitHub item.

const (
	ItemTypeIssue       ItemType = "issue"
	ItemTypePullRequest ItemType = "pull"
	ItemTypeDiscussion  ItemType = "discussion"
)

type ParentIssueNode

type ParentIssueNode struct {
	ID         string `json:"id"`
	Number     int    `json:"number"`
	Title      string `json:"title"`
	URL        string `json:"url"`
	State      string `json:"state"`
	Repository struct {
		Owner struct {
			Login string `json:"login"`
		} `json:"owner"`
		Name string `json:"name"`
	} `json:"repository"`
}

ParentIssueNode represents a parent issue in the GraphQL response.

type ParsedInput

type ParsedInput struct {
	Owner    string
	Repo     string
	Number   int      // 0 if fetching all
	ItemType ItemType // Empty if fetching all types
}

ParsedInput represents parsed command input (URL or owner/repo).

func ParseInput

func ParseInput(input string) (*ParsedInput, error)

ParseInput parses the input argument which can be a URL or owner/repo format.

type PullRequest

type PullRequest struct {
	ID            string         `json:"id"`
	URL           string         `json:"url"`
	Number        int            `json:"number"`
	Owner         string         `json:"owner"`
	Repo          string         `json:"repo"`
	Title         string         `json:"title"`
	Body          string         `json:"body"`
	State         string         `json:"state"`
	Author        string         `json:"author"`
	Draft         bool           `json:"draft"`
	Labels        []string       `json:"labels"`
	Assignees     []string       `json:"assignees"`
	HeadRef       string         `json:"headRef"`
	BaseRef       string         `json:"baseRef"`
	MergeCommit   string         `json:"mergeCommit,omitempty"`
	CreatedAt     time.Time      `json:"createdAt"`
	UpdatedAt     time.Time      `json:"updatedAt"`
	MergedAt      time.Time      `json:"mergedAt,omitempty"`
	Comments      []Comment      `json:"comments"`
	ReviewThreads []ReviewThread `json:"reviewThreads"`
}

PullRequest represents a GitHub pull request with all metadata.

type PullRequestNode

type PullRequestNode struct {
	ID     string `json:"id"`
	URL    string `json:"url"`
	Number int    `json:"number"`
	Title  string `json:"title"`
	Body   string `json:"body"`
	State  string `json:"state"`
	Author struct {
		Login string `json:"login"`
	} `json:"author"`
	IsDraft     bool      `json:"isDraft"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
	MergedAt    time.Time `json:"mergedAt"`
	HeadRefName string    `json:"headRefName"`
	BaseRefName string    `json:"baseRefName"`
	MergeCommit struct {
		Oid string `json:"oid"`
	} `json:"mergeCommit"`
	Labels struct {
		Nodes []struct {
			Name string `json:"name"`
		} `json:"nodes"`
	} `json:"labels"`
	Assignees struct {
		Nodes []struct {
			Login string `json:"login"`
		} `json:"nodes"`
	} `json:"assignees"`
	Comments struct {
		Nodes []struct {
			ID        string    `json:"id"`
			Body      string    `json:"body"`
			CreatedAt time.Time `json:"createdAt"`
			UpdatedAt time.Time `json:"updatedAt"`
			Author    struct {
				Login string `json:"login"`
			} `json:"author"`
		} `json:"nodes"`
	} `json:"comments"`
	ReviewThreads struct {
		Nodes []struct {
			ID         string `json:"id"`
			Path       string `json:"path"`
			Line       int    `json:"line"`
			IsResolved bool   `json:"isResolved"`
			IsOutdated bool   `json:"isOutdated"`
			Comments   struct {
				Nodes []struct {
					ID        string    `json:"id"`
					Body      string    `json:"body"`
					CreatedAt time.Time `json:"createdAt"`
					UpdatedAt time.Time `json:"updatedAt"`
					Author    struct {
						Login string `json:"login"`
					} `json:"author"`
				} `json:"nodes"`
			} `json:"comments"`
		} `json:"nodes"`
	} `json:"reviewThreads"`
}

PullRequestNode represents a PR in the GraphQL response.

type PullRequestsResponse

type PullRequestsResponse struct {
	Repository struct {
		PullRequests struct {
			PageInfo struct {
				HasNextPage bool   `json:"hasNextPage"`
				EndCursor   string `json:"endCursor"`
			} `json:"pageInfo"`
			Nodes []PullRequestNode `json:"nodes"`
		} `json:"pullRequests"`
	} `json:"repository"`
}

PullRequestsResponse represents the GraphQL response for pull requests.

type RemoteComment

type RemoteComment struct {
	ID   string
	Body string
}

RemoteComment represents a comment fetched from GitHub for comparison.

type RemoteState

type RemoteState struct {
	UpdatedAt time.Time
	State     string // "OPEN", "CLOSED", "MERGED" (PRs only)
}

RemoteState holds the remote item's current state info.

type ReviewComment

type ReviewComment struct {
	ID        string    `json:"id"`
	Author    string    `json:"author"`
	Body      string    `json:"body"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

ReviewComment represents an inline review comment on a PR.

type ReviewThread

type ReviewThread struct {
	ID         string          `json:"id"`
	Path       string          `json:"path"`
	Line       int             `json:"line"`
	IsResolved bool            `json:"isResolved"`
	IsOutdated bool            `json:"isOutdated"`
	Comments   []ReviewComment `json:"comments"`
}

ReviewThread represents a review thread on a PR (a conversation on a specific line).

type SingleDiscussionResponse

type SingleDiscussionResponse struct {
	Repository struct {
		Discussion DiscussionNode `json:"discussion"`
	} `json:"repository"`
}

SingleDiscussionResponse represents the GraphQL response for a single discussion.

type SingleIssueResponse

type SingleIssueResponse struct {
	Repository struct {
		Issue IssueNode `json:"issue"`
	} `json:"repository"`
}

SingleIssueResponse represents the GraphQL response for a single issue.

type SinglePullRequestResponse

type SinglePullRequestResponse struct {
	Repository struct {
		PullRequest PullRequestNode `json:"pullRequest"`
	} `json:"repository"`
}

SinglePullRequestResponse represents the GraphQL response for a single PR.

type SubIssueNode

type SubIssueNode struct {
	ID         string `json:"id"`
	Number     int    `json:"number"`
	Title      string `json:"title"`
	URL        string `json:"url"`
	State      string `json:"state"`
	Repository struct {
		Owner struct {
			Login string `json:"login"`
		} `json:"owner"`
		Name string `json:"name"`
	} `json:"repository"`
}

SubIssueNode represents a sub-issue in the GraphQL response.

type SubIssuesSummary

type SubIssuesSummary struct {
	Total           int `json:"total"`
	Completed       int `json:"completed"`
	PercentComplete int `json:"percentComplete"`
}

SubIssuesSummary provides statistics about sub-issues.

type SubIssuesSummaryNode

type SubIssuesSummaryNode struct {
	Total            int `json:"total"`
	Completed        int `json:"completed"`
	PercentCompleted int `json:"percentCompleted"`
}

SubIssuesSummaryNode represents the sub-issues summary in the GraphQL response.

Jump to

Keyboard shortcuts

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