github

package
v0.0.0-...-d95f06a Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package github wraps go-github to provide the data types and API calls needed by the ght TUI.

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 wraps the authenticated go-github client.

func New

func New(token string) *Client

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

func (c *Client) GetFileContent(ctx context.Context, owner, repo, path string) (string, error)

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

func (c *Client) ListContents(ctx context.Context, owner, repo, path string) ([]*FileEntry, error)

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

func (c *Client) ListIssues(ctx context.Context, owner, repo string) ([]*Issue, error)

ListIssues returns open issues for owner/repo (PRs excluded).

func (*Client) ListOrgRepos

func (c *Client) ListOrgRepos(ctx context.Context, org string) ([]*Repo, error)

ListOrgRepos returns repositories belonging to org.

func (*Client) ListOrgs

func (c *Client) ListOrgs(ctx context.Context) ([]*gogithub.Organization, error)

ListOrgs returns organisations the authenticated user belongs to.

func (*Client) ListPRs

func (c *Client) ListPRs(ctx context.Context, owner, repo string) ([]*PR, error)

ListPRs returns open pull requests for owner/repo.

func (*Client) ListRepos

func (c *Client) ListRepos(ctx context.Context) ([]*Repo, error)

ListRepos returns repositories owned by the authenticated user.

func (*Client) ListWorkflowRuns

func (c *Client) ListWorkflowRuns(ctx context.Context, owner, repo string) ([]*WorkflowRun, error)

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

type IssueComment struct {
	Author    string
	Body      string
	CreatedAt string
}

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 PRFile

type PRFile struct {
	Filename  string
	Status    string
	Additions int
	Deletions int
}

PRFile is a single changed file in a pull request.

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.

type WorkflowRun

type WorkflowRun struct {
	ID         int64
	Name       string
	Status     string
	Conclusion string
	Branch     string
	Event      string
	CommitMsg  string
	Actor      string
	StartedAt  string
}

WorkflowRun is a simplified workflow-run record.

type WorkflowStep

type WorkflowStep struct {
	Number     int64
	Name       string
	Status     string
	Conclusion string
}

WorkflowStep is a single step inside a workflow job.

Jump to

Keyboard shortcuts

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