github

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package github implements forge.Forge against the GitHub REST API. It is reached only through the forge.Forge interface; no view imports it.

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 adapts the GitHub SDK to forge.Forge.

func New

func New(profile, host, token string, transport http.RoundTripper) (*Client, error)

New builds a Client for one profile/host pair using a token obtained from the gh CLI. A host other than github.com is treated as GitHub Enterprise.

func (*Client) Capabilities

func (c *Client) Capabilities() forge.Caps

Capabilities reports what GitHub accepts. A multi-line suggestion is expressed by the comment's own line range rather than in the fence.

func (*Client) Comment

func (c *Client) Comment(ctx context.Context, ref forge.Ref, target, body string) error

Comment posts a note. GitHub comments on issues and pull requests through the same endpoint, so the target's kind does not matter here.

func (*Client) CreateDiffThread

func (c *Client) CreateDiffThread(ctx context.Context, ref forge.Ref, mr int, dc forge.DiffComment) error

CreateDiffThread opens a review comment anchored to a place in the diff.

GitHub positions against the commit the diff was read at, and rejects the comment outright if that commit is no longer the head — which is the right behaviour: a line number from a diff that has since been force-pushed points at something else now.

func (*Client) CreateThread

func (c *Client) CreateThread(ctx context.Context, ref forge.Ref, target, body string) error

CreateThread posts a comment.

GitHub's issue comments are flat, so a "thread" is a single comment; the review-comment endpoint needs a diff position gu does not carry.

func (*Client) FileContent

func (c *Client) FileContent(ctx context.Context, ref forge.Ref, path, rev string) ([]byte, error)

FileContent returns a file's bytes at a revision.

func (*Client) GroupIssues

func (c *Client) GroupIssues(ctx context.Context, group string, f forge.IssueFilter) ([]forge.Issue, error)

GroupIssues lists issues across an organisation's repositories.

GitHub's org issue endpoint only covers repositories the user is a member of, which is the closest equivalent to a GitLab group board.

func (*Client) Issue

func (c *Client) Issue(ctx context.Context, ref forge.Ref, id int) (forge.Issue, error)

Issue fetches one issue by its number.

func (*Client) Issues

func (c *Client) Issues(ctx context.Context, ref forge.Ref, f forge.IssueFilter) ([]forge.Issue, error)

Issues lists a repository's issues.

GitHub's issue endpoint also returns pull requests; they are filtered out so an issue list means the same thing on both providers.

func (*Client) JobLog

func (c *Client) JobLog(ctx context.Context, ref forge.Ref, jobID int) (io.ReadCloser, error)

JobLog downloads a job's log.

GitHub answers with a redirect to storage rather than the log itself, so this follows that URL and streams the body.

func (*Client) Jobs

func (c *Client) Jobs(ctx context.Context, ref forge.Ref, pipelineID int) ([]forge.Job, error)

Jobs lists the steps of one workflow run.

func (*Client) Merge

func (c *Client) Merge(ctx context.Context, ref forge.Ref, mr int) error

Merge merges a pull request.

func (*Client) MergeRequest

func (c *Client) MergeRequest(ctx context.Context, ref forge.Ref, mr int) (forge.MergeRequest, error)

MergeRequest fetches one pull request by its number.

func (*Client) MergeRequestDiff

func (c *Client) MergeRequestDiff(ctx context.Context, ref forge.Ref, mr int) (string, error)

MergeRequestDiff returns the pull request as a unified diff.

GitHub serves one directly, so unlike GitLab there are no headers to reconstruct.

func (*Client) MergeRequests

func (c *Client) MergeRequests(ctx context.Context, ref forge.Ref, f forge.MRFilter) ([]forge.MergeRequest, error)

MergeRequests lists a repository's pull requests.

func (*Client) MyWork

func (c *Client) MyWork(ctx context.Context, f forge.MyWorkFilter) ([]forge.WorkItem, error)

MyWork lists the current user's issues and pull requests across every repository, using the search API — the only endpoint that spans repos.

func (*Client) Namespaces

func (c *Client) Namespaces(ctx context.Context, parent string) ([]forge.Namespace, error)

Namespaces lists the user's organisations.

GitHub has no nested groups, so only the root level has anything to show; asking for the children of an organisation yields none.

func (*Client) Pipelines

func (c *Client) Pipelines(ctx context.Context, ref forge.Ref, f forge.PipelineFilter) ([]forge.Pipeline, error)

Pipelines lists a repository's Actions workflow runs.

func (*Client) Rebase

func (c *Client) Rebase(ctx context.Context, ref forge.Ref, mr int) error

Rebase brings a pull request up to date with its base branch through GitHub's update-branch endpoint. gu never runs git locally.

func (*Client) Repos

func (c *Client) Repos(ctx context.Context, namespace string) ([]forge.Repo, error)

Repos lists an organisation's repositories, falling back to the user's own when the name is not an organisation.

func (*Client) RetryPipeline

func (c *Client) RetryPipeline(ctx context.Context, ref forge.Ref, pipelineID int) error

RetryPipeline re-runs a workflow run.

func (*Client) SetFields

func (c *Client) SetFields(ctx context.Context, ref forge.Ref, target string, patch forge.FieldPatch) error

SetFields applies a partial update to an issue or pull request.

func (*Client) Starred

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

Starred lists the current user's starred repositories.

func (*Client) Threads

func (c *Client) Threads(ctx context.Context, ref forge.Ref, target string) ([]forge.Thread, error)

Threads lists the comments on an issue or pull request, together with the events in its history.

GitHub serves issue and pull-request comments through one endpoint, and they are flat: each becomes a thread of one. The history comes from the timeline endpoint and arrives as system notes, so a detail page can draw one activity stream whichever provider it is talking to. Review conversations live on a third endpoint and are not folded in here.

func (*Client) Tree

func (c *Client) Tree(ctx context.Context, ref forge.Ref, path, rev string) ([]forge.TreeEntry, error)

Tree lists the entries directly under a path.

GetContents already returns one directory level, which is exactly what a file browser descends through — no need for the recursive tree API.

func (*Client) Whoami

func (c *Client) Whoami(ctx context.Context) (forge.User, error)

Whoami identifies the authenticated user.

Jump to

Keyboard shortcuts

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