github

package
v0.4.168 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package github adapts GitHub REST and GraphQL APIs to gitprovider read models.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrValidation identifies non-retryable adapter input or GitHub validation failures.
	ErrValidation = errors.New("github: validation error")
	// ErrUnhandledGraphQL identifies non-retryable GraphQL errors not covered by the provider taxonomy.
	ErrUnhandledGraphQL = errors.New("github: unhandled graphql error")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a GitHub read adapter. CR-10 adds write methods and full gitprovider.GitProvider satisfaction.

func New

func New(opts Options) (*Client, error)

New builds a GitHub client from explicit options.

func NewFromGitConfig

func NewFromGitConfig(git config.GitConfig, store TokenStore, opts Options) (*Client, gitprovider.Credential, error)

NewFromGitConfig builds a GitHub client and credential from config plus a token store.

func (*Client) Capabilities

func (c *Client) Capabilities() gitprovider.ProviderCaps

Capabilities returns GitHub feature support.

func (*Client) GetDiff

GetDiff returns the raw unified diff for a pull request.

func (*Client) GetDiffBetweenRefs added in v0.3.56

func (c *Client) GetDiffBetweenRefs(ctx context.Context, ref gitprovider.PRRef, baseSHA, headSHA string) (gitprovider.UnifiedDiff, error)

GetDiffBetweenRefs returns the raw unified diff between two git refs in the pull request's base repository.

func (*Client) GetFileAtRef

func (c *Client) GetFileAtRef(ctx context.Context, ref gitprovider.PRRef, gitRef string, filePath string) ([]byte, error)

GetFileAtRef returns raw file contents at a git ref.

func (*Client) GetPR

func (c *Client) GetPR(ctx context.Context, ref gitprovider.PRRef) (gitprovider.PR, error)

GetPR returns one pull request snapshot.

func (*Client) Host

func (c *Client) Host() string

Host returns the normalized host this client is bound to.

func (*Client) ListInlineThreads

func (c *Client) ListInlineThreads(ctx context.Context, ref gitprovider.PRRef) ([]gitprovider.InlineThread, error)

ListInlineThreads returns inline review threads and their comments.

func (*Client) ListIssueComments

func (c *Client) ListIssueComments(ctx context.Context, ref gitprovider.PRRef) ([]gitprovider.IssueComment, error)

ListIssueComments returns all issue comments on the pull request's issue.

func (*Client) ListReviews

func (c *Client) ListReviews(ctx context.Context, ref gitprovider.PRRef) ([]gitprovider.Review, error)

ListReviews returns all pull request reviews.

func (*Client) ListTreeAtRef

func (c *Client) ListTreeAtRef(ctx context.Context, ref gitprovider.PRRef, gitRef string, treePath string) ([]gitprovider.TreeEntry, error)

ListTreeAtRef returns tree entries for a path at a git ref.

func (*Client) PostInlineComment

func (c *Client) PostInlineComment(ctx context.Context, ref gitprovider.PRRef, comment gitprovider.InlineComment) (gitprovider.CommentID, error)

PostInlineComment posts a line- or file-scoped pull request review comment.

func (*Client) PostIssueComment

func (c *Client) PostIssueComment(ctx context.Context, ref gitprovider.PRRef, body string) (gitprovider.CommentID, error)

PostIssueComment posts a pull-request issue comment.

func (*Client) ReplyToThread

func (c *Client) ReplyToThread(ctx context.Context, ref gitprovider.PRRef, threadID gitprovider.ThreadID, body string) (gitprovider.CommentID, error)

ReplyToThread posts a reply to an existing pull request review thread.

func (*Client) ResolveThread

func (c *Client) ResolveThread(ctx context.Context, ref gitprovider.PRRef, threadID gitprovider.ThreadID) error

ResolveThread resolves an existing pull request review thread.

func (*Client) SubmitReview

func (c *Client) SubmitReview(ctx context.Context, ref gitprovider.PRRef, request gitprovider.ReviewRequest) (gitprovider.ReviewID, error)

SubmitReview submits the final pull-request review event.

func (*Client) WhoAmI

WhoAmI returns the identity for the supplied credential.

type InstallationLookup added in v0.3.78

type InstallationLookup struct {
	Owner string
	Repo  string
}

InstallationLookup carries repository context for GitHub App installation lookup.

type Options

type Options struct {
	Host               string
	Token              string
	HTTPClient         *http.Client
	BaseURL            string
	GraphQLURL         string
	Now                func() time.Time
	InstallationLookup *InstallationLookup
}

Options configures a GitHub client.

type TokenStore

type TokenStore interface {
	Exists(profile, key string) (bool, error)
	Get(profile, key string) (string, error)
}

TokenStore is the minimal credential-store dependency needed by the adapter factory.

Jump to

Keyboard shortcuts

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