Documentation
¶
Overview ¶
Package github implements forge.Forge with the gh CLI.
Index ¶
- type Forge
- func (f *Forge) Checks(ctx context.Context, repo git.Repo, numbers []int) (map[int]forge.CheckSummary, error)
- func (f *Forge) ClosePR(ctx context.Context, repo git.Repo, number int, comment string) error
- func (f *Forge) CreatePR(ctx context.Context, repo git.Repo, in forge.CreatePR) (forge.PullRequest, error)
- func (f *Forge) CreateStack(ctx context.Context, repo git.Repo, numbers []int) (forge.StackRef, error)
- func (f *Forge) ListPRs(ctx context.Context, repo git.Repo) ([]forge.PullRequest, error)
- func (f *Forge) MergeStack(ctx context.Context, repo git.Repo, number int, method forge.MergeMethod) (forge.MergeOutcome, error)
- func (f *Forge) PullRequestURL(ctx context.Context, repo git.Repo, number int) (string, error)
- func (f *Forge) RenameBranch(ctx context.Context, repo git.Repo, from, to string) error
- func (f *Forge) UpdatePR(ctx context.Context, repo git.Repo, number int, in forge.UpdatePR) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Forge ¶
type Forge struct {
// contains filtered or unexported fields
}
Forge talks to GitHub through gh.
func (*Forge) Checks ¶ added in v0.2.0
func (f *Forge) Checks(ctx context.Context, repo git.Repo, numbers []int) (map[int]forge.CheckSummary, error)
Checks asks GitHub for the status check rollup of each pull request's head commit in one GraphQL request, with an aliased pullRequest field per number. The repository is the one gh resolves for the checkout ({owner} and {repo}), the same one MergeStack merges in. A pull request with more than checksPageSize checks has the rest read in follow up requests, one per page for all the pull requests that still have more.
func (*Forge) ClosePR ¶ added in v0.4.0
ClosePR closes a pull request with a comment, through gh pr close. gh refuses one that is already closed or merged, which counts as done.
func (*Forge) CreatePR ¶
func (f *Forge) CreatePR(ctx context.Context, repo git.Repo, in forge.CreatePR) (forge.PullRequest, error)
CreatePR opens a pull request and returns it.
func (*Forge) CreateStack ¶ added in v0.3.0
func (f *Forge) CreateStack(ctx context.Context, repo git.Repo, numbers []int) (forge.StackRef, error)
CreateStack groups pull requests into a new stack on GitHub, bottom to top. The id is kept as its decimal string, the form gh stack records.
func (*Forge) ListPRs ¶
ListPRs returns every pull request of the repository whose head branch lives in this repository (forks are skipped), newest first as gh orders.
func (*Forge) MergeStack ¶ added in v0.1.5
func (f *Forge) MergeStack(ctx context.Context, repo git.Repo, number int, method forge.MergeMethod) (forge.MergeOutcome, error)
MergeStack merges a pull request and every open pull request below it in its stack through GitHub's asynchronous merge endpoint, the only one that accepts stacked pull requests, and polls until it settles.
func (*Forge) PullRequestURL ¶ added in v0.2.0
PullRequestURL builds https://<host>/<owner>/<repo>/pull/<number> from the repository's remotes, picking the repository the way gh does: the one `gh repo set-default` chose (remote.<name>.gh-resolved is "base" for that remote's own repository, or an explicit OWNER/REPO on that remote's host, e.g. the upstream when only a fork is a remote), then upstream, github, origin, then the first remote. Remote URLs are resolved the way git resolves them (url.<base>.insteadOf applies), and nothing but local git config is read.
func (*Forge) RenameBranch ¶ added in v0.4.0
RenameBranch renames a branch through GitHub's branch rename endpoint, which moves its open pull request with it and retargets the ones based on it.