github

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 16 Imported by: 1 module, 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 github implements forge.Forge with the gh CLI.

Index

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 New

func New(r exec.Runner) *Forge

New returns a Forge using r to run 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

func (f *Forge) ClosePR(ctx context.Context, repo git.Repo, number int, comment string) error

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

func (f *Forge) ListPRs(ctx context.Context, repo git.Repo) ([]forge.PullRequest, error)

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

func (f *Forge) PullRequestURL(ctx context.Context, repo git.Repo, number int) (string, error)

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

func (f *Forge) RenameBranch(ctx context.Context, repo git.Repo, from, to string) error

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.

func (*Forge) UpdatePR

func (f *Forge) UpdatePR(ctx context.Context, repo git.Repo, number int, in forge.UpdatePR) error

UpdatePR edits title, body and base, and can mark a draft ready.

Jump to

Keyboard shortcuts

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