github

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package github implements the forge.IssueTracker interface for GitHub using the google/go-github SDK.

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 implements forge.IssueTracker for GitHub repositories.

func New

func New(owner, repo string, httpClient *http.Client) *Client

New creates a GitHub IssueTracker client for the given owner/repo. The httpClient should carry authentication (e.g., via oauth2.TokenSource). If httpClient is nil, unauthenticated requests are made (60 req/hr limit).

func (*Client) AddComment

func (c *Client) AddComment(ctx context.Context, number int, body string) (*forge.Comment, error)

AddComment posts a new comment on the given issue.

func (*Client) AddLabel

func (c *Client) AddLabel(ctx context.Context, number int, label string) error

AddLabel adds a single label to the given issue.

func (*Client) Assign

func (c *Client) Assign(ctx context.Context, number int, assignee string) error

Assign adds an assignee to the given issue.

func (*Client) CreateIssue

func (c *Client) CreateIssue(ctx context.Context, req *forge.CreateIssueRequest) (*forge.Issue, error)

CreateIssue creates a new issue on the repository.

func (*Client) CreatePullRequest

func (c *Client) CreatePullRequest(ctx context.Context, req *forge.CreatePRRequest) (*forge.PullRequest, error)

CreatePullRequest creates a new pull request on the repository.

func (*Client) GetCommitLog

func (c *Client) GetCommitLog(ctx context.Context, branch string, limit int) ([]forge.Commit, error)

GetCommitLog returns the most recent commits on a branch. If branch is empty, "main" is used. Limit defaults to 20 if <= 0.

func (*Client) GetDiff

func (c *Client) GetDiff(ctx context.Context, base, head string) (string, error)

GetDiff returns the diff between two refs (branches, tags, or commit SHAs).

func (*Client) GetIssue

func (c *Client) GetIssue(ctx context.Context, number int) (*forge.Issue, error)

GetIssue retrieves a single issue by number.

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(ctx context.Context, number int) (*forge.PullRequest, error)

GetPullRequest retrieves a single pull request by number.

func (*Client) ListBranches

func (c *Client) ListBranches(ctx context.Context) ([]forge.Branch, error)

ListBranches returns all branches in the repository.

func (*Client) ListComments

func (c *Client) ListComments(ctx context.Context, number int) ([]*forge.Comment, error)

ListComments returns all comments on the given issue.

func (*Client) ListFiles

func (c *Client) ListFiles(ctx context.Context, path, ref string) ([]forge.FileEntry, error)

ListFiles returns the files and directories at the given path and ref. If path is empty, the repository root is listed. If ref is empty, the default branch is used.

func (*Client) ListIssues

func (c *Client) ListIssues(ctx context.Context, opts *forge.ListOptions) ([]*forge.Issue, error)

ListIssues returns issues matching the given filter options.

func (*Client) ListPullRequests

func (c *Client) ListPullRequests(ctx context.Context, opts *forge.ListPROptions) ([]*forge.PullRequest, error)

ListPullRequests returns pull requests matching the given filter options.

func (*Client) MergePullRequest

func (c *Client) MergePullRequest(ctx context.Context, number int, method forge.MergeMethod, commitMsg string) error

MergePullRequest merges a pull request using the specified method.

func (*Client) ReadFile

func (c *Client) ReadFile(ctx context.Context, path, ref string) ([]byte, error)

ReadFile returns the contents of the file at the given path and ref. If ref is empty, the default branch is used. Uses GetContents which returns base64-encoded content (limited to 1 MB files).

func (*Client) RemoveLabel

func (c *Client) RemoveLabel(ctx context.Context, number int, label string) error

RemoveLabel removes a single label from the given issue.

func (*Client) SearchCode

func (c *Client) SearchCode(ctx context.Context, query string) ([]forge.SearchResult, error)

SearchCode searches for code matching the query within this repository.

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(url string)

SetBaseURL overrides the GitHub API base URL (useful for GitHub Enterprise or test servers). The URL must include a trailing slash.

func (*Client) SetLabels

func (c *Client) SetLabels(ctx context.Context, number int, labels []string) error

SetLabels replaces all labels on the given issue.

func (*Client) SetPollInterval

func (c *Client) SetPollInterval(d time.Duration)

SetPollInterval configures the polling interval for Watch.

func (*Client) Unassign

func (c *Client) Unassign(ctx context.Context, number int, assignee string) error

Unassign removes an assignee from the given issue.

func (*Client) UpdateIssue

func (c *Client) UpdateIssue(ctx context.Context, number int, req *forge.UpdateIssueRequest) (*forge.Issue, error)

UpdateIssue modifies an existing issue. Nil fields in the request are left unchanged.

func (*Client) Watch

func (c *Client) Watch(ctx context.Context, handler func(forge.Event)) error

Watch polls the GitHub API for issue changes and calls handler for each detected event. It blocks until the context is cancelled. The initial poll establishes baseline state; subsequent polls emit events for changes.

Jump to

Keyboard shortcuts

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