Documentation
¶
Overview ¶
Package github wraps go-github to provide the data types and API calls needed by the ght TUI.
Index ¶
- type Client
- func (c *Client) GetFileContent(ctx context.Context, owner, repo, path string) (string, error)
- func (c *Client) GetHeadCommit(ctx context.Context, owner, repo string) (sha, message string, err error)
- func (c *Client) GetIssueDetail(ctx context.Context, owner, repo string, number int) (*IssueDetail, error)
- func (c *Client) GetPRDetail(ctx context.Context, owner, repo string, number int) (*PRDetail, error)
- func (c *Client) GetWorkflowRunJobs(ctx context.Context, owner, repo string, runID int64) ([]*WorkflowJobDetail, error)
- func (c *Client) ListContents(ctx context.Context, owner, repo, path string) ([]*FileEntry, error)
- func (c *Client) ListIssues(ctx context.Context, owner, repo string) ([]*Issue, error)
- func (c *Client) ListOrgRepos(ctx context.Context, org string) ([]*Repo, error)
- func (c *Client) ListOrgs(ctx context.Context) ([]*gogithub.Organization, error)
- func (c *Client) ListPRs(ctx context.Context, owner, repo string) ([]*PR, error)
- func (c *Client) ListRepos(ctx context.Context) ([]*Repo, error)
- func (c *Client) ListWorkflowRuns(ctx context.Context, owner, repo string) ([]*WorkflowRun, error)
- type FileEntry
- type Issue
- type IssueComment
- type IssueDetail
- type PR
- type PRDetail
- type PRFile
- type Repo
- type WorkflowJobDetail
- type WorkflowRun
- type WorkflowStep
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 wraps the authenticated go-github client.
func New ¶
New returns an OAuth2-authenticated GitHub client.
context.Background() is intentional: StaticTokenSource never refreshes, so the context is only used for the initial TLS handshake.
func (*Client) GetFileContent ¶
GetFileContent returns the decoded text content of a file.
For files >1 MB the GitHub Contents API returns an error; this method falls back to DownloadContents (raw file download) which has no size limit. Symlinks are resolved via DownloadContents. Submodules return a descriptive error.
func (*Client) GetHeadCommit ¶
func (c *Client) GetHeadCommit(ctx context.Context, owner, repo string) (sha, message string, err error)
GetHeadCommit returns the short SHA and first line of the most-recent commit on the repository's default branch. Uses a lightweight ref lookup rather than a full commit-list API call.
func (*Client) GetIssueDetail ¶
func (c *Client) GetIssueDetail(ctx context.Context, owner, repo string, number int) (*IssueDetail, error)
GetIssueDetail fetches the full issue body and all comments.
func (*Client) GetPRDetail ¶
func (c *Client) GetPRDetail(ctx context.Context, owner, repo string, number int) (*PRDetail, error)
GetPRDetail fetches the full PR body and complete list of changed files.
func (*Client) GetWorkflowRunJobs ¶
func (c *Client) GetWorkflowRunJobs(ctx context.Context, owner, repo string, runID int64) ([]*WorkflowJobDetail, error)
GetWorkflowRunJobs fetches all jobs (and their steps) for a workflow run, paginating through all pages.
func (*Client) ListContents ¶
ListContents returns the directory entries at path in owner/repo.
Note: the GitHub Contents API returns at most 1000 items per directory with no pagination support. Large directories (e.g. node_modules, vendor trees) will be silently truncated.
func (*Client) ListIssues ¶
ListIssues returns open issues for owner/repo (PRs excluded).
func (*Client) ListOrgRepos ¶
ListOrgRepos returns repositories belonging to org.
func (*Client) ListWorkflowRuns ¶
ListWorkflowRuns returns the 30 most-recent workflow runs for owner/repo.
type FileEntry ¶
type FileEntry struct {
Name string
Path string
Type string // "file", "dir", "symlink", or "submodule"
Size int
}
FileEntry represents a file or directory in a repository tree.
type Issue ¶
type Issue struct {
Number int
Title string
State string
Author string
Labels []string
Comments int
CreatedAt string
}
Issue is a simplified issue record.
type IssueComment ¶
IssueComment is a single comment on an issue.
type IssueDetail ¶
type IssueDetail struct {
Number int
Title string
State string
Author string
Labels []string
Comments int
CreatedAt string
Body string
CommentList []*IssueComment
CommentErr string // non-empty when comment fetch failed
}
IssueDetail is the full record for a single issue, including body and comments.
type PR ¶
type PR struct {
Number int
Title string
State string
Author string
Base string
Head string
Draft bool
CreatedAt string
}
PR is a simplified pull-request record.
type PRDetail ¶
type PRDetail struct {
Number int
Title string
State string
Author string
Base string
Head string
Draft bool
CreatedAt string
Body string
Additions int
Deletions int
Files []*PRFile
FileErr string // non-empty when file list fetch failed
}
PRDetail is the full record for a single pull request, including changed files.
type Repo ¶
type Repo struct {
Owner string
Name string
FullName string
Private bool
OrgName string // empty for personal repos
}
Repo is a simplified repository record.
type WorkflowJobDetail ¶
type WorkflowJobDetail struct {
Name string
Status string
Conclusion string
Steps []*WorkflowStep
}
WorkflowJobDetail is a single job in a workflow run, with its steps.