githubclient

package
v0.0.0-...-dca90b0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package githubclient is Nosey's native GitHub adapter over go-github. It runs no gh subprocess and its exported API exposes no go-github types.

Index

Constants

View Source
const (
	KindRateLimited gitclient.Kind = "GitHub rate limit exceeded"
	KindInvalid     gitclient.Kind = "GitHub rejected the request"
)

Kinds reuse gitclient's error classification; these add API-only cases.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a token-scoped GitHub API client for one host.

func New

func New(ctx context.Context, options Options) (*Client, error)

New resolves the host's token and constructs a Client. An Enterprise host gets a token only when gh knows it, GH_HOST names it, or Credentials.TrustedHosts lists it.

func (*Client) Authenticated

func (c *Client) Authenticated() bool

Authenticated reports whether the client holds a token.

func (*Client) CreatePullRequest

func (c *Client) CreatePullRequest(ctx context.Context, request CreatePullRequestRequest) (PullRequest, error)

CreatePullRequest opens a pull request.

func (*Client) CreateRepository

func (c *Client) CreateRepository(ctx context.Context, request CreateRepositoryRequest) (Repository, error)

CreateRepository creates a repository for the authenticated user when Owner is that user or empty, otherwise in the organization named by Owner.

func (*Client) FindPullRequest

func (c *Client) FindPullRequest(ctx context.Context, owner, repo, head, base string) (PullRequest, bool, error)

FindPullRequest returns the open pull request from head into base. Found is false when there is none. The head filter uses the repository owner.

func (*Client) GetRepository

func (c *Client) GetRepository(ctx context.Context, owner, name string) (Repository, error)

GetRepository returns owner/name.

func (*Client) UpdateDefaultWorkflowPermissions

func (c *Client) UpdateDefaultWorkflowPermissions(ctx context.Context, owner, name string, permissions WorkflowPermissions) error

UpdateDefaultWorkflowPermissions sets the repository's Actions defaults.

type CreatePullRequestRequest

type CreatePullRequestRequest struct {
	Owner string
	Repo  string
	Base  string
	Head  string
	Title string
	Body  string
}

CreatePullRequestRequest describes a new pull request.

type CreateRepositoryRequest

type CreateRepositoryRequest struct {
	Owner   string
	Name    string
	Private bool
}

CreateRepositoryRequest describes a new repository.

type Error

type Error struct {
	Kind   gitclient.Kind
	Op     string
	Status int
	// RateReset is when a rate limit lifts, if known.
	RateReset time.Time
	Err       error
}

Error is a classified API failure.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

Is matches on the error's Kind, with gitclient kinds as targets.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying cause.

type Options

type Options struct {
	// Host is the GitHub host; empty means github.com. An Enterprise host is the
	// origin host of the repository being operated on.
	Host string
	// Credentials resolves the token; nil uses the operating system's.
	Credentials *gitclient.Credentials
	// RequireAuth fails construction when no token is available. Use it for writes.
	RequireAuth bool
	// Timeout bounds each API request; zero uses 30 seconds.
	Timeout time.Duration
	// BaseURL replaces the API base URL. Test seam for httptest.
	BaseURL string
}

Options configure a Client.

type PullRequest

type PullRequest struct {
	Number  int
	URL     string
	Head    string
	Base    string
	Title   string
	IsDraft bool
}

PullRequest is an open pull request.

type Repository

type Repository struct {
	Owner         string
	Name          string
	Private       bool
	DefaultBranch string
	HTMLURL       string
	CloneURL      string
	SSHURL        string
}

Repository describes a GitHub repository.

type WorkflowPermissions

type WorkflowPermissions struct {
	// Default is "read" or "write".
	Default string
	// CanApprovePullRequests lets Actions open and approve pull requests.
	CanApprovePullRequests bool
}

WorkflowPermissions are a repository's default GitHub Actions permissions.

Jump to

Keyboard shortcuts

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