Documentation
¶
Overview ¶
Package github is the GitHub adapter: the only code in Ghostbranch that imports a GitHub API client.
Index ¶
- Variables
- type Client
- func (c *Client) AddToStack(ctx context.Context, full string, stack int, prs []int) (forge.Stack, error)
- func (c *Client) CancelRun(ctx context.Context, full string, id int64) error
- func (c *Client) ChecksLimited(full string) bool
- func (c *Client) ClosePullRequest(ctx context.Context, full string, number int) error
- func (c *Client) CreatePR(ctx context.Context, full string, in forge.NewPR) (forge.PR, error)
- func (c *Client) CreatePrivateRepo(ctx context.Context, full string) (forge.Repo, error)
- func (c *Client) CreateStack(ctx context.Context, full string, prs []int) (forge.Stack, error)
- func (c *Client) CurrentUser(ctx context.Context) (forge.User, error)
- func (c *Client) EditPR(ctx context.Context, full string, number int, title, body *string) error
- func (c *Client) FindOpenPR(ctx context.Context, full, head, base string) (*forge.PR, error)
- func (c *Client) ForceCancelRun(ctx context.Context, full string, id int64) error
- func (c *Client) GetPR(ctx context.Context, full string, number int) (forge.PR, error)
- func (c *Client) GetRepo(ctx context.Context, full string) (forge.Repo, error)
- func (c *Client) InstallationRepos(ctx context.Context, id int64) ([]string, error)
- func (c *Client) ListChecks(ctx context.Context, full, sha string) ([]forge.Check, error)
- func (c *Client) OAuthScopes(ctx context.Context) ([]string, bool, error)
- func (c *Client) ProbePermissions(ctx context.Context, full string) (forge.RepoPermissions, error)
- func (c *Client) PushAccess(ctx context.Context, full string) forge.PushAccess
- func (c *Client) PushRuns(ctx context.Context, full, sha string) ([]forge.Run, error)
- func (c *Client) SecretNames(ctx context.Context, full string) ([]string, error)
- func (c *Client) SetDefaultBranch(ctx context.Context, full, branch string) error
- func (c *Client) StackOf(ctx context.Context, full string, pr int) (*forge.Stack, error)
- func (c *Client) UserInstallations(ctx context.Context) ([]forge.Installation, error)
- func (c *Client) WithGitBase(base string) *Client
Constants ¶
This section is empty.
Variables ¶
var ErrNoToken = errors.New("github: no token")
ErrNoToken means New was given an empty token. Ghostbranch never builds an unauthenticated client: it would read public repos and then fail on private ones with confusing 404s.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewWithBaseURL ¶
NewWithBaseURL points the client at another API root (tests).
func (*Client) AddToStack ¶
func (c *Client) AddToStack(ctx context.Context, full string, stack int, prs []int) (forge.Stack, error)
AddToStack appends prs, bottom first, to stack number stack (forge.Stacker): POST /repos/{o}/{r}/stacks/{n}/add.
func (*Client) CancelRun ¶
CancelRun asks GitHub to cancel workflow run id. GitHub answers 202, which only accepts the request; a 409 (forge.ErrConflict) means GitHub won't cancel the run in its current state, often because it has finished.
func (*Client) ChecksLimited ¶
ChecksLimited reports whether ListChecks had to fall back to workflow runs for full because the token cannot read check runs. Third-party check apps are invisible in that mode.
func (*Client) ClosePullRequest ¶
ClosePullRequest closes PR number. Closing a closed PR is a no-op on GitHub; a plain 403 is forge.ErrForbidden.
func (*Client) CreatePrivateRepo ¶
func (*Client) CreateStack ¶
CreateStack makes a native stack of prs, bottom first (forge.Stacker): POST /repos/{o}/{r}/stacks.
func (*Client) EditPR ¶
EditPR changes PR number's title and body; a nil field is not sent, so GitHub leaves it as it is. A plain 403 is forge.ErrForbidden.
func (*Client) FindOpenPR ¶
func (*Client) ForceCancelRun ¶
ForceCancelRun force-cancels workflow run id, for a run that ignored CancelRun. go-github has no wrapper, so this is a raw request; GitHub answers 202.
func (*Client) InstallationRepos ¶ added in v0.2.0
InstallationRepos lists the repos installation id covers that the user can also access (forge.Installer): GET /user/installations/{id}/repositories, every page.
func (*Client) ListChecks ¶
ListChecks merges check runs and legacy commit statuses for sha.
func (*Client) OAuthScopes ¶
OAuthScopes reads a classic token's scopes from GET /user's X-OAuth-Scopes header (forge.PermissionProber).
func (*Client) ProbePermissions ¶
ProbePermissions learns what the token may do on full with read calls only (forge.PermissionProber). A fine-grained token can't be asked what it may write, so only Contents: write is probed, through PushAccess.
func (*Client) PushAccess ¶
PushAccess asks GitHub's git endpoint for push discovery. GitHub answers 200 only when the token may write, and 403 when it may not. Nothing is pushed. The REST permissions field is not used: it reflects the user's role, not what a fine-grained token may do.
func (*Client) SecretNames ¶
SecretNames lists the Actions secret names of full and the org secrets shared with it, sorted and de-duplicated. Values are never read. A user repo has no org secrets, so a 404 on that listing is not an error.
func (*Client) SetDefaultBranch ¶
func (*Client) StackOf ¶
StackOf is the stack PR pr is in (forge.Stacker). The PR carries its stack's number even once merged; a PR without one, as on a host without native stacks, is nil, and so is one whose stack dissolved between the two reads (the stack is a 404).
func (*Client) UserInstallations ¶ added in v0.2.0
UserInstallations lists the app's installs the user can see (forge.Installer): GET /user/installations, every page.
func (*Client) WithGitBase ¶
WithGitBase points git smart-HTTP probes at another host (tests).