Documentation
¶
Index ¶
- type AssigneeNode
- type Client
- func (c *Client) AddComment(subjectID, body string) error
- func (c *Client) AddDiscussionComment(discussionID, body string) error
- func (c *Client) AddDiscussionCommentReply(replyToID, body string) error
- func (c *Client) AddReviewThreadReply(threadID, body string) error
- func (c *Client) CloseIssue(id string) error
- func (c *Client) ClosePullRequest(id string) error
- func (c *Client) FetchComments(itemType ItemType, owner, repo string, number int) ([]RemoteComment, error)
- func (c *Client) FetchDiscussion(owner, repo string, number int) (*Discussion, error)
- func (c *Client) FetchDiscussions(owner, repo string, limit int, openOnly bool, since *time.Time, ...) ([]Discussion, error)
- func (c *Client) FetchIssue(owner, repo string, number int) (*Issue, error)
- func (c *Client) FetchIssues(owner, repo string, limit int, openOnly bool, since *time.Time, ...) ([]Issue, error)
- func (c *Client) FetchPullRequest(owner, repo string, number int) (*PullRequest, error)
- func (c *Client) FetchPullRequests(owner, repo string, limit int, openOnly bool, since *time.Time, ...) ([]PullRequest, error)
- func (c *Client) FetchRemoteState(itemType ItemType, owner, repo string, number int) (RemoteState, error)
- func (c *Client) Query(query string, variables map[string]interface{}, response interface{}) error
- func (c *Client) ReopenIssue(id string) error
- func (c *Client) ReopenPullRequest(id string) error
- func (c *Client) UpdateDiscussion(id, title, body string) error
- func (c *Client) UpdateDiscussionComment(commentID, body string) error
- func (c *Client) UpdateIssue(id, title, body string) error
- func (c *Client) UpdateIssueComment(commentID, body string) error
- func (c *Client) UpdatePullRequest(id, title, body string) error
- type Comment
- type Discussion
- type DiscussionComment
- type DiscussionCommentNode
- type DiscussionNode
- type DiscussionsResponse
- type Issue
- type IssueNode
- type IssueReference
- type IssuesResponse
- type ItemType
- type LabelNode
- type ParentIssueNode
- type ParsedInput
- type ProgressFunc
- type PullRequest
- type PullRequestNode
- type PullRequestsResponse
- type RemoteComment
- type RemoteState
- type ReviewComment
- type ReviewThread
- type SingleDiscussionResponse
- type SingleIssueResponse
- type SinglePullRequestResponse
- type SubIssueNode
- type SubIssuesSummary
- type SubIssuesSummaryNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssigneeNode ¶ added in v0.2.0
type AssigneeNode struct {
Login string `json:"login"`
}
AssigneeNode represents an assignee in the GraphQL response.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides methods to interact with GitHub's GraphQL API.
func (*Client) AddComment ¶
AddComment adds a new comment to an issue or PR.
func (*Client) AddDiscussionComment ¶
AddDiscussionComment adds a new comment to a discussion.
func (*Client) AddDiscussionCommentReply ¶
AddDiscussionCommentReply adds a reply to a discussion comment.
func (*Client) AddReviewThreadReply ¶
AddReviewThreadReply adds a reply to a PR review thread.
func (*Client) CloseIssue ¶
CloseIssue closes an issue.
func (*Client) ClosePullRequest ¶
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, openOnly bool, since *time.Time, progress ProgressFunc) ([]Discussion, error)
FetchDiscussions fetches all discussions from a repository with pagination. If openOnly is true, only OPEN discussions are fetched; otherwise all states are fetched. If since is provided, fetching stops when encountering items older than the timestamp. If progress is non-nil, it's called after each page with the current count.
func (*Client) FetchIssue ¶
FetchIssue fetches a single issue by number.
func (*Client) FetchIssues ¶
func (c *Client) FetchIssues(owner, repo string, limit int, openOnly bool, since *time.Time, progress ProgressFunc) ([]Issue, error)
FetchIssues fetches all issues from a repository with pagination. If openOnly is true, only OPEN issues are fetched; otherwise all states are fetched. If since is provided, fetching stops when encountering items older than the timestamp. If progress is non-nil, it's called after each page with the current count.
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, openOnly bool, since *time.Time, progress ProgressFunc) ([]PullRequest, error)
FetchPullRequests fetches all PRs from a repository with pagination. If openOnly is true, only OPEN PRs are fetched; otherwise all states are fetched. If since is provided, fetching stops when encountering items older than the timestamp. If progress is non-nil, it's called after each page with the current count.
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) ReopenIssue ¶
ReopenIssue reopens an issue.
func (*Client) ReopenPullRequest ¶
ReopenPullRequest reopens a pull request.
func (*Client) UpdateDiscussion ¶
UpdateDiscussion updates a discussion's title and body.
func (*Client) UpdateDiscussionComment ¶
UpdateDiscussionComment updates an existing discussion comment.
func (*Client) UpdateIssue ¶
UpdateIssue updates an issue's title and body.
func (*Client) UpdateIssueComment ¶
UpdateIssueComment updates an existing comment on an issue or PR.
func (*Client) UpdatePullRequest ¶
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"`
State string `json:"state"`
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.
func (*Discussion) GetNumber ¶ added in v0.2.0
func (d *Discussion) GetNumber() int
GetNumber returns the number for Discussion.
func (*Discussion) GetOwner ¶ added in v0.2.0
func (d *Discussion) GetOwner() string
GetOwner returns the owner for Discussion.
func (*Discussion) GetRepo ¶ added in v0.2.0
func (d *Discussion) GetRepo() string
GetRepo returns the repo for Discussion.
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"`
Closed bool `json:"closed"`
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 []LabelNode `json:"nodes"`
} `json:"labels"`
Assignees struct {
Nodes []AssigneeNode `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.
func ItemTypeFromDirName ¶ added in v0.2.0
ItemTypeFromDirName converts a local directory name or URL path segment into an ItemType. Accepted values: "issue", "issues", "pull", "pulls", "discussion", "discussions".
func (ItemType) DirName ¶ added in v0.2.0
DirName returns the local storage directory name for an item type.
func (ItemType) DisplayPlural ¶ added in v0.2.0
DisplayPlural returns the human-readable plural form.
func (ItemType) ListLabel ¶ added in v0.2.0
ListLabel returns a short label used for displaying an item type in lists.
func (ItemType) URLSegment ¶ added in v0.2.0
URLSegment returns the GitHub web URL path segment for an item type.
type LabelNode ¶ added in v0.2.0
type LabelNode struct {
Name string `json:"name"`
}
LabelNode represents a label in the GraphQL response.
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 ProgressFunc ¶ added in v0.2.0
type ProgressFunc func(fetched int)
ProgressFunc is called during paginated fetches with the current count of fetched items.
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"`
Reviewers []string `json:"reviewers"`
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.
func (*PullRequest) GetNumber ¶ added in v0.2.0
func (p *PullRequest) GetNumber() int
GetNumber returns the number for PullRequest.
func (*PullRequest) GetOwner ¶ added in v0.2.0
func (p *PullRequest) GetOwner() string
GetOwner returns the owner for PullRequest.
func (*PullRequest) GetRepo ¶ added in v0.2.0
func (p *PullRequest) GetRepo() string
GetRepo returns the repo for PullRequest.
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 []LabelNode `json:"nodes"`
} `json:"labels"`
Assignees struct {
Nodes []AssigneeNode `json:"nodes"`
} `json:"assignees"`
ReviewRequests struct {
Nodes []struct {
RequestedReviewer struct {
Login string `json:"login"` // User
Name string `json:"name"` // Team
} `json:"requestedReviewer"`
} `json:"nodes"`
} `json:"reviewRequests"`
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 ¶
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.