github

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 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 is the GitHub adapter of the forge interface: it reads GitHub through the gh command, and opens or refreshes a PR only through the forge.PRs methods in pulls.go; it never merges. It tells a missing or unauthenticated gh, and a repo with no GitHub remote, apart from an answer of "not found".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client reads GitHub for the repo in its directory.

func New

func New(dir string) *Client

New returns a Client that runs the real gh in dir.

func NewWithRunner

func NewWithRunner(dir string, r Runner) *Client

NewWithRunner returns a Client that uses r instead of gh. r is not given the body of a PR, so it suits the reads; see NewWithStdinRunner.

func NewWithStdinRunner

func NewWithStdinRunner(dir string, r StdinRunner) *Client

NewWithStdinRunner returns a Client that uses r instead of gh, and gives r what gh would read on stdin.

func (*Client) ChangeLogins

func (c *Client) ChangeLogins(ids []string) (map[string]string, error)

ChangeLogins asks GitHub, 100 changes a query, for each change's author's login. A change GitHub does not know, or whose author has no account, is left out.

func (*Client) ChangePR

func (c *Client) ChangePR(change string) (forge.PR, bool, error)

ChangePR returns the PR change came from, with its people's review and discussion and its commits, oldest first. Its bool is false when change came from no PR or GitHub does not know it. Reviews still pending are left out: only their author can see them.

func (*Client) CreatePR

func (c *Client) CreatePR(head, base, title, body string) (n int, url string, err error)

CreatePR opens a PR from branch head into branch base, with body on gh's stdin. It returns the new PR's number and URL.

func (*Client) EditPR

func (c *Client) EditPR(n int, body string) error

EditPR replaces the body of PR n, with the body on gh's stdin.

func (*Client) Login

func (c *Client) Login() (string, error)

Login returns the login of the GitHub account gh is signed in as. It is not part of forge.Forge: only the person running Physa needs it. Failures are classed as gh's others are, so a missing gh is forge.ErrUnavailable and a signed-out one forge.ErrUnauthenticated.

func (*Client) MergedPRs

func (c *Client) MergedPRs(since time.Time, max int) ([]forge.PR, bool, error)

MergedPRs returns the PRs merged at or after since, newest merge first, at most max, with their people's review and the issues they close. more is true when max stopped the list before since did. A max below 1 returns nothing. GitHub orders pages by update time, and a PR merged after since was updated after it, so paging stops at the first page that reaches back past since.

func (*Client) Name

func (c *Client) Name() string

Name is "github".

func (*Client) OpenPR

func (c *Client) OpenPR(head string) (n int, url string, ok bool, err error)

OpenPR returns the open PR whose head is the branch head. Its bool is false when none is open.

func (*Client) PRExists

func (c *Client) PRExists(n int) (bool, error)

PRExists reports whether the repo has a pull request numbered n.

type Error

type Error struct {
	Args     []string
	Stderr   string
	ExitCode int
}

Error is a gh command that exited non-zero.

func (*Error) Error

func (e *Error) Error() string

type Runner

type Runner func(dir string, args ...string) (stdout []byte, err error)

Runner runs gh with args in dir and returns its stdout, also when gh exits non-zero (gh api prints GraphQL errors there).

type StdinRunner

type StdinRunner func(dir string, stdin []byte, args ...string) (stdout []byte, err error)

StdinRunner is a Runner that also passes stdin to gh when it is not nil.

Jump to

Keyboard shortcuts

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