github

package
v0.0.0-...-15cb2bd Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package github implements provider.Provider against the GitHub REST API using google/go-github. The go-github package is imported under the alias gh to avoid colliding with this package's own name.

Phase 0 note: PushCommits writes through the Git Data API rather than a local clone. See the package README section on PushCommits for the Phase 1 caveat.

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 API to provider.Provider.

func New

func New(token, apiBaseURL string) (*Client, error)

New builds a GitHub-backed provider authenticated with token. When apiBaseURL is non-empty it targets a GitHub Enterprise Server instance; otherwise it targets github.com.

func (*Client) AddIssueLabel

func (c *Client) AddIssueLabel(ctx context.Context, repo provider.Repo, issueNumber int, label string) error

AddIssueLabel adds label to the issue.

func (*Client) ClosePullRequest

func (c *Client) ClosePullRequest(ctx context.Context, repo provider.Repo, number int) error

ClosePullRequest closes the pull request without merging.

func (*Client) CommentOnIssue

func (c *Client) CommentOnIssue(ctx context.Context, repo provider.Repo, issueNumber int, body string) error

CommentOnIssue posts body as a comment on the issue.

func (*Client) CommentOnPullRequest

func (c *Client) CommentOnPullRequest(ctx context.Context, repo provider.Repo, number int, body string) error

CommentOnPullRequest posts body as a comment on the pull request. On GitHub a PR is also an issue (shared numbering), so this uses the same issue-comment endpoint as CommentOnIssue.

func (*Client) CreateBranch

func (c *Client) CreateBranch(ctx context.Context, repo provider.Repo, branch, fromRef string) error

CreateBranch creates branch pointing at fromRef (a branch name or SHA).

func (*Client) DefaultBranch

func (c *Client) DefaultBranch(ctx context.Context, repo provider.Repo) (string, error)

DefaultBranch returns the repo's default branch name.

func (*Client) DeleteBranch

func (c *Client) DeleteBranch(ctx context.Context, repo provider.Repo, branch string) error

DeleteBranch deletes branch.

func (*Client) FindOpenPullRequestByHead

func (c *Client) FindOpenPullRequestByHead(ctx context.Context, repo provider.Repo, headBranch string) (*provider.PullRequest, error)

FindOpenPullRequestByHead returns an open pull request for headBranch, or nil.

func (*Client) GetIssue

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

GetIssue fetches a single issue by number, without its comment thread.

func (*Client) GetPullRequest

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

GetPullRequest fetches a pull request by number regardless of its state.

func (*Client) ListLabeledIssues

func (c *Client) ListLabeledIssues(ctx context.Context, repo provider.Repo, label string) ([]provider.Issue, error)

ListLabeledIssues returns open issues carrying label. The GitHub issues API also returns pull requests, so those are skipped via IsPullRequest.

func (*Client) ListRepoDir

func (c *Client) ListRepoDir(ctx context.Context, repo provider.Repo, ref, path string) ([]string, error)

ListRepoDir returns the entry names at path, at ref (the repo's default branch when ref is empty). Directory entries are suffixed with "/". The empty path lists the repo root.

func (*Client) MergePullRequest

func (c *Client) MergePullRequest(ctx context.Context, repo provider.Repo, number int, opts provider.MergeOptions) error

MergePullRequest merges the pull request identified by number, optionally deleting its head branch afterwards.

func (*Client) Name

func (c *Client) Name() string

Name implements provider.Provider.

func (*Client) OpenPullRequest

func (c *Client) OpenPullRequest(ctx context.Context, repo provider.Repo, spec provider.PullRequestSpec) (*provider.PullRequest, error)

OpenPullRequest opens a pull request per spec.

func (*Client) PushCommits

func (c *Client) PushCommits(ctx context.Context, repo provider.Repo, branch string, commits []provider.Commit) (string, error)

PushCommits creates each commit in order on branch through the Git Data API and returns the resulting head SHA. No local clone is involved (Phase 0).

func (*Client) ReadRepoFile

func (c *Client) ReadRepoFile(ctx context.Context, repo provider.Repo, ref, path string) (string, error)

ReadRepoFile returns the content of the file at path, at ref (the repo's default branch when ref is empty). Returns ErrNotFound when path does not exist or is a directory.

func (*Client) RemoveIssueLabel

func (c *Client) RemoveIssueLabel(ctx context.Context, repo provider.Repo, issueNumber int, label string) error

RemoveIssueLabel removes label from the issue. GitHub returns 404 when the label is already absent; treat that as success.

func (*Client) UpdatePullRequestBase

func (c *Client) UpdatePullRequestBase(ctx context.Context, repo provider.Repo, number int, baseBranch string) error

UpdatePullRequestBase retargets the pull request onto a new base branch.

Jump to

Keyboard shortcuts

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