githubclient

package
v8.79.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsExecution

func IsExecution(err error) bool

IsExecution asserts executionError.

func IsInstallationNotFound

func IsInstallationNotFound(err error) bool

IsInstallationNotFound asserts installationNotFoundError.

func IsInvalidConfig

func IsInvalidConfig(err error) bool

IsInvalidConfig asserts invalidConfigError.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound asserts notFoundError.

func IsPRMergeTimeout

func IsPRMergeTimeout(err error) bool

IsPRMergeTimeout asserts prMergeTimeoutError.

func NewConditional added in v8.79.0

func NewConditional(config Config) (*Client, *Conditional, error)

NewConditional is New for a poll loop: every GET is a conditional request through a Conditional, whose Rate the caller reads for its interval. The client is read-only in practice (DryRun is not applied) and config.BaseURL is used as given, with no /api/v3/ suffix: it names the REST API root itself (api.github.com, or a test double serving /repos/... at its root).

Types

type Client

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

func New

func New(config Config) (*Client, error)

func (*Client) AddRepoToRenovatePermissions

func (c *Client) AddRepoToRenovatePermissions(ctx context.Context, org string, repo *github.Repository) error

Add repository to the Renovate installation. Corresponds to https://docs.github.com/en/rest/apps/installations?apiVersion=2022-11-28#add-a-repository-to-an-app-installation

func (*Client) CheckRunsForRef added in v8.79.0

func (c *Client) CheckRunsForRef(ctx context.Context, owner, repo, ref string) ([]*github.CheckRun, error)

CheckRunsForRef returns the check runs of ref as the merge box lists them: the latest run per check name and app (GitHub's filter=latest), every page.

func (*Client) CloneRepository

func (c *Client) CloneRepository(ctx context.Context, owner, repo, workDir string) error

func (*Client) CommitAndPush

func (c *Client) CommitAndPush(ctx context.Context, owner, repo, branch, message string) error

func (*Client) CommitStatuses added in v8.79.0

func (c *Client) CommitStatuses(ctx context.Context, owner, repo, ref string) ([]*github.RepoStatus, error)

CommitStatuses returns the commit statuses of ref, the latest per context (the combined status), every page.

func (*Client) CreateBranch

func (c *Client) CreateBranch(ctx context.Context, newBranch string) error

func (*Client) CreateFromTemplate

func (c *Client) CreateFromTemplate(ctx context.Context, templateOwner, templateRepo, newOwner string, repository *github.Repository) (*github.Repository, error)

func (*Client) CreatePullRequest

func (c *Client) CreatePullRequest(ctx context.Context, owner, repo, head, title string) (*github.PullRequest, error)

func (*Client) FileExists added in v8.79.0

func (c *Client) FileExists(ctx context.Context, owner, repo, path, ref string) (bool, error)

FileExists says whether path is a file at ref.

func (*Client) GetFile

func (c *Client) GetFile(ctx context.Context, owner, repo, path, ref string) (RepositoryFile, error)

func (*Client) GetRepository

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

func (*Client) GetUnderlyingClient

func (c *Client) GetUnderlyingClient(ctx context.Context) *github.Client

GetUnderlyingClient returns the underlying go-github client.

func (*Client) ListRepositories

func (c *Client) ListRepositories(ctx context.Context, owner string) ([]Repository, error)

func (*Client) PullRequest added in v8.79.0

func (c *Client) PullRequest(ctx context.Context, owner, repo string, number int) (*github.PullRequest, error)

PullRequest returns the pull request as GitHub sees it now: state, draft, mergeable state, head and base.

func (*Client) RemoveRepoFromRenovatePermissions

func (c *Client) RemoveRepoFromRenovatePermissions(ctx context.Context, org string, repo *github.Repository) error

Remove repository from the Renovate installation. Corresponds to https://docs.github.com/en/rest/apps/installations?apiVersion=2022-11-28#remove-a-repository-from-an-app-installation

func (*Client) RemoveRepositoryBranchProtection

func (c *Client) RemoveRepositoryBranchProtection(ctx context.Context, repository *github.Repository) (err error)

func (*Client) ReportedChecks added in v8.49.0

func (c *Client) ReportedChecks(ctx context.Context, repository *github.Repository, branch string) ([]string, error)

ReportedChecks returns the names of the commit status contexts and the completed, non-skipped check runs observed on the latest non-tag commit of branch and on the heads of the most recently merged pull requests: the checks that demonstrably run in this repository. Callers use it to require a check only once it exists (devctl repo checks --checks-if-reported).

func (*Client) RequiredStatusContexts added in v8.79.0

func (c *Client) RequiredStatusContexts(ctx context.Context, owner, repo, branch string) ([]string, error)

RequiredStatusContexts returns the status contexts branch requires before a merge: the required status checks of its branch protection and of every ruleset in effect on it, sorted and without duplicates. A protection the token may not read (404: none, or 403: no admin access) contributes nothing; the rules endpoint answers for everyone with read access.

func (*Client) SetRepositoryBranchProtection

func (c *Client) SetRepositoryBranchProtection(ctx context.Context, repository *github.Repository, checkNames []string, checksFilter *regexp.Regexp) (err error)

func (*Client) SetRepositoryDefaultBranch

func (c *Client) SetRepositoryDefaultBranch(ctx context.Context, repository *github.Repository, newDefaultBranch string) (err error)

func (*Client) SetRepositoryPermissions

func (c *Client) SetRepositoryPermissions(ctx context.Context, repository *github.Repository, permissions map[string]string) error

func (*Client) SetRepositorySettings

func (c *Client) SetRepositorySettings(ctx context.Context, repository, repositorySettings *github.Repository) (*github.Repository, error)

func (*Client) SetRepositoryWebhooks

func (c *Client) SetRepositoryWebhooks(ctx context.Context, repository *github.Repository, hook *github.Hook) error

func (*Client) WaitForPRMerge

func (c *Client) WaitForPRMerge(ctx context.Context, owner, repo string, prNumber int, timeout time.Duration) error

func (*Client) WorkflowRunsForSHA added in v8.79.0

func (c *Client) WorkflowRunsForSHA(ctx context.Context, owner, repo, sha string) ([]*github.WorkflowRun, error)

WorkflowRunsForSHA returns every GitHub Actions run of the head SHA, whatever its status, every page.

type Conditional added in v8.79.0

type Conditional struct {
	// Base sends the requests; nil means http.DefaultTransport.
	Base http.RoundTripper
	// contains filtered or unexported fields
}

Conditional is an http.RoundTripper that makes every GET a conditional request: it keeps the ETag and body of the last 200 per URL, sends the tag as If-None-Match and replays the kept body when GitHub answers 304 Not Modified. A 304 does not count against the rate limit, so a poll loop that sees no change costs nothing; go-github never sees the 304, it reads a 200 with the same body as before.

It also remembers the rate-limit headers of the newest answer, 304 or not, so a poll loop derives its interval from real responses and never asks the rate_limit endpoint.

func (*Conditional) Rate added in v8.79.0

func (c *Conditional) Rate() RateLimit

Rate is the budget the newest response reported.

func (*Conditional) Replayed added in v8.79.0

func (c *Conditional) Replayed() int

Replayed is how many 304 answers were replayed from the cache.

func (*Conditional) RoundTrip added in v8.79.0

func (c *Conditional) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper.

type Config

type Config struct {
	Logger      *logrus.Logger
	AccessToken string
	DryRun      bool
	// BaseURL points the client at another GitHub API host (an enterprise
	// instance, a test double); empty means api.github.com.
	BaseURL string
}

type RateLimit added in v8.79.0

type RateLimit struct {
	// Known is false before the first response with rate-limit headers.
	Known     bool
	Remaining int
	Reset     time.Time
}

RateLimit is what the newest response said about the budget.

type Repository

type Repository struct {
	Name      string
	Language  string
	Owner     string
	UpdatedAt time.Time
}

type RepositoryFile

type RepositoryFile struct {
	Data []byte
	Path string
}

Jump to

Keyboard shortcuts

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