Documentation
¶
Index ¶
- func IsExecution(err error) bool
- func IsInstallationNotFound(err error) bool
- func IsInvalidConfig(err error) bool
- func IsMergeDeclined(err error) bool
- func IsNotFound(err error) bool
- func IsPRMergeTimeout(err error) bool
- func NewConditional(config Config) (*Client, *Conditional, error)
- type Client
- func (c *Client) AddRepoToRenovatePermissions(ctx context.Context, org string, repo *github.Repository) error
- func (c *Client) CheckRunsForRef(ctx context.Context, owner, repo, ref string) ([]*github.CheckRun, error)
- func (c *Client) CloneRepository(ctx context.Context, owner, repo, workDir string) error
- func (c *Client) CommitAndPush(ctx context.Context, owner, repo, branch, message string) error
- func (c *Client) CommitStatuses(ctx context.Context, owner, repo, ref string) ([]*github.RepoStatus, error)
- func (c *Client) CreateBranch(ctx context.Context, newBranch string) error
- func (c *Client) CreateFromTemplate(ctx context.Context, templateOwner, templateRepo, newOwner string, ...) (*github.Repository, error)
- func (c *Client) CreatePullRequest(ctx context.Context, owner, repo, head, title string) (*github.PullRequest, error)
- func (c *Client) CurrentLogin(ctx context.Context) (string, error)
- func (c *Client) DeleteBranch(ctx context.Context, owner, repo, branch string) error
- func (c *Client) EnqueuePullRequest(ctx context.Context, nodeID string) error
- func (c *Client) FileExists(ctx context.Context, owner, repo, path, ref string) (bool, error)
- func (c *Client) FindTagForCommit(ctx context.Context, owner, repo, sha string) (string, error)
- func (c *Client) GetFile(ctx context.Context, owner, repo, path, ref string) (RepositoryFile, error)
- func (c *Client) GetPullRequestMerge(ctx context.Context, owner, repo string, number int) (PullRequestMerge, error)
- func (c *Client) GetReleaseByTag(ctx context.Context, owner, repo, tag string) (Release, error)
- func (c *Client) GetRepository(ctx context.Context, owner, repo string) (*github.Repository, error)
- func (c *Client) GetTagSHA(ctx context.Context, owner, repo, tag string) (string, error)
- func (c *Client) GetUnderlyingClient(ctx context.Context) *github.Client
- func (c *Client) GitHub() *github.Client
- func (c *Client) IsPrivateRepository(ctx context.Context, owner, repo string) (bool, error)
- func (c *Client) ListDirectory(ctx context.Context, owner, repo, path, ref string) ([]string, error)
- func (c *Client) ListRepositories(ctx context.Context, owner string) ([]Repository, error)
- func (c *Client) ListWorkflowRunsForSHA(ctx context.Context, owner, repo, sha string) ([]WorkflowRun, error)
- func (c *Client) MergePullRequest(ctx context.Context, owner, repo string, number int, opts MergeOptions) (string, error)
- func (c *Client) MergeQueueRequired(ctx context.Context, owner, repo, branch string) (bool, error)
- func (c *Client) PullRequest(ctx context.Context, owner, repo string, number int) (*github.PullRequest, error)
- func (c *Client) RemoveRepoFromRenovatePermissions(ctx context.Context, org string, repo *github.Repository) error
- func (c *Client) RemoveRepositoryBranchProtection(ctx context.Context, repository *github.Repository) (err error)
- func (c *Client) ReportedChecks(ctx context.Context, repository *github.Repository, branch string) ([]string, error)
- func (c *Client) RequiredStatusContexts(ctx context.Context, owner, repo, branch string) ([]string, error)
- func (c *Client) SetRepositoryBranchProtection(ctx context.Context, repository *github.Repository, checkNames []string, ...) (err error)
- func (c *Client) SetRepositoryDefaultBranch(ctx context.Context, repository *github.Repository, newDefaultBranch string) (err error)
- func (c *Client) SetRepositoryPermissions(ctx context.Context, repository *github.Repository, ...) error
- func (c *Client) SetRepositorySettings(ctx context.Context, repository, repositorySettings *github.Repository) (*github.Repository, error)
- func (c *Client) SetRepositoryWebhooks(ctx context.Context, repository *github.Repository, hook *github.Hook) error
- func (c *Client) UpdatePullRequestBranch(ctx context.Context, owner, repo string, number int, expectedHeadSHA string) error
- func (c *Client) WaitForPRMerge(ctx context.Context, owner, repo string, prNumber int, timeout time.Duration) error
- func (c *Client) WorkflowRunsForSHA(ctx context.Context, owner, repo, sha string) ([]*github.WorkflowRun, error)
- type Conditional
- type Config
- type MergeMethod
- type MergeOptions
- type PullRequestMerge
- type RateLimit
- type Release
- type ReleaseAsset
- type Repository
- type RepositoryFile
- type WorkflowRun
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsInstallationNotFound ¶
IsInstallationNotFound asserts installationNotFoundError.
func IsInvalidConfig ¶
IsInvalidConfig asserts invalidConfigError.
func IsMergeDeclined ¶ added in v8.82.0
IsMergeDeclined asserts mergeDeclinedError: GitHub declined the merge as the pull request stands (405, a rule or the merge box blocks it; 409, the head moved since it was judged). Its message is GitHub's.
func IsPRMergeTimeout ¶
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 (*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 (*Client) CommitAndPush ¶
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 (*Client) CreateFromTemplate ¶
func (c *Client) CreateFromTemplate(ctx context.Context, templateOwner, templateRepo, newOwner string, repository *github.Repository) (*github.Repository, error)
func (*Client) CreatePullRequest ¶
func (*Client) CurrentLogin ¶ added in v8.82.0
CurrentLogin is the login the token acts as (GET /user).
func (*Client) DeleteBranch ¶ added in v8.82.0
DeleteBranch deletes refs/heads/branch through the refs API. A branch that is gone already (GitHub deleted it on merge, or answers 404) is not an error: the outcome is the same.
func (*Client) EnqueuePullRequest ¶ added in v8.82.0
EnqueuePullRequest adds the pull request to its base's merge queue: the GraphQL mutation enqueuePullRequest, REST has no call for it. The endpoint is <REST root>/graphql, api.github.com's layout. The queue merges when its checks pass; the caller waits on the pull request.
func (*Client) FileExists ¶ added in v8.79.0
FileExists says whether path is a file at ref.
func (*Client) FindTagForCommit ¶ added in v8.81.0
FindTagForCommit returns the newest tag pointing at sha, or "" when the newest tags do not include one.
func (*Client) GetPullRequestMerge ¶ added in v8.81.0
func (c *Client) GetPullRequestMerge(ctx context.Context, owner, repo string, number int) (PullRequestMerge, error)
GetPullRequestMerge returns the merge state of a pull request.
func (*Client) GetReleaseByTag ¶ added in v8.81.0
GetReleaseByTag returns the release of a tag; IsNotFound when there is none.
func (*Client) GetRepository ¶
func (*Client) GetTagSHA ¶ added in v8.81.0
GetTagSHA returns the commit a tag points at, through an annotated tag object when the tag is one. IsNotFound when the tag does not exist.
func (*Client) GetUnderlyingClient ¶
GetUnderlyingClient returns the underlying go-github client.
func (*Client) GitHub ¶ added in v8.82.0
GitHub is the underlying go-github client, for the packages that take one (pkg/reposetup's Remote). It shares the token and the transport.
func (*Client) IsPrivateRepository ¶ added in v8.81.0
IsPrivateRepository says whether owner/repo is private.
func (*Client) ListDirectory ¶ added in v8.81.0
func (c *Client) ListDirectory(ctx context.Context, owner, repo, path, ref string) ([]string, error)
ListDirectory returns the names of the entries of a directory at ref (files and directories alike). IsNotFound when the path does not exist.
func (*Client) ListRepositories ¶
func (*Client) ListWorkflowRunsForSHA ¶ added in v8.81.0
func (c *Client) ListWorkflowRunsForSHA(ctx context.Context, owner, repo, sha string) ([]WorkflowRun, error)
ListWorkflowRunsForSHA returns the Actions runs on a commit, newest first, as WorkflowRun values.
func (*Client) MergePullRequest ¶ added in v8.82.0
func (c *Client) MergePullRequest(ctx context.Context, owner, repo string, number int, opts MergeOptions) (string, error)
MergePullRequest merges the pull request through the merge API and returns the merge commit's SHA. GitHub's refusal of the merge as the pull request stands is IsMergeDeclined; anything else is a tooling failure.
func (*Client) MergeQueueRequired ¶ added in v8.82.0
MergeQueueRequired says whether a merge queue rule is in effect on branch: the rules endpoint of the branch lists one of type merge_queue. A repository whose rules the token may not read has none.
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 (*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 (*Client) SetRepositoryDefaultBranch ¶
func (*Client) SetRepositoryPermissions ¶
func (*Client) SetRepositorySettings ¶
func (c *Client) SetRepositorySettings(ctx context.Context, repository, repositorySettings *github.Repository) (*github.Repository, error)
func (*Client) SetRepositoryWebhooks ¶
func (*Client) UpdatePullRequestBranch ¶ added in v8.82.0
func (c *Client) UpdatePullRequestBranch(ctx context.Context, owner, repo string, number int, expectedHeadSHA string) error
UpdatePullRequestBranch asks GitHub to merge the base into the head (the "Update branch" button). GitHub schedules it and answers 202; the new head appears on the pull request a moment later. expectedHeadSHA guards against updating a head that moved meanwhile.
func (*Client) WaitForPRMerge ¶
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.
type MergeMethod ¶ added in v8.82.0
type MergeMethod string
MergeMethod is how the head lands on the base.
const ( // MergeSquash lands the head as one commit. MergeSquash MergeMethod = "squash" // MergeRebase lands every commit of the head, rebased. MergeRebase MergeMethod = "rebase" )
type MergeOptions ¶ added in v8.82.0
type MergeOptions struct {
// Method is squash or rebase.
Method MergeMethod
// HeadSHA is the head the merge is for: GitHub refuses (409) when the
// head moved since it was judged.
HeadSHA string
// CommitTitle is the squash commit's subject; empty leaves GitHub's
// default. A rebase merge keeps the commits' own subjects.
CommitTitle string
}
MergeOptions configure Client.MergePullRequest.
type PullRequestMerge ¶ added in v8.81.0
type PullRequestMerge struct {
Number int
State string
Merged bool
// MergeCommitSHA is the commit on the base branch; empty until merged.
MergeCommitSHA string
MergedAt time.Time
}
PullRequestMerge is what release wait reads of a pull request.
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 Release ¶ added in v8.81.0
type Release struct {
URL string
// Published: not a draft.
Published bool
Assets []ReleaseAsset
}
Release is a GitHub release as release wait reads it.
type ReleaseAsset ¶ added in v8.81.0
ReleaseAsset is one uploaded asset with the digest GitHub reports for it.