Documentation
¶
Overview ¶
Package github implements scm.Host backed by the gh CLI.
Index ¶
- func HostPrefixedSlug(remoteURL string) string
- func HostPrefixedSlugForHost(remoteURL, host string) string
- func RepoSlug(remoteURL string) string
- type CmdFactory
- type Host
- func (h *Host) Available(ctx context.Context) error
- func (h *Host) Capabilities() scm.Capabilities
- func (h *Host) CreatePR(ctx context.Context, branch, base string, content scm.PRContent) (*scm.PR, error)
- func (h *Host) FetchFailedCheckLogs(ctx context.Context, _ *scm.PR, branch, headSHA string, failingNames []string) (string, error)
- func (h *Host) FindAttestationPublicationIdentity(ctx context.Context, headSHA, publicationNonce string) (scm.CheckAttemptIdentity, bool, error)
- func (h *Host) FindPR(ctx context.Context, branch, base string) (*scm.PR, error)
- func (h *Host) GetCheckAttemptIdentity(ctx context.Context, check scm.Check) (scm.CheckAttemptIdentity, error)
- func (h *Host) GetChecks(ctx context.Context, pr *scm.PR) ([]scm.Check, error)
- func (h *Host) GetMergeableState(ctx context.Context, pr *scm.PR) (scm.MergeableState, error)
- func (h *Host) GetPRState(ctx context.Context, pr *scm.PR) (scm.PRState, error)
- func (h *Host) Provider() scm.Provider
- func (h *Host) RerunCheck(ctx context.Context, _ *scm.PR, check scm.Check) error
- func (h *Host) UpdatePR(ctx context.Context, pr *scm.PR, content scm.PRContent) (*scm.PR, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HostPrefixedSlug ¶
HostPrefixedSlug returns "host/owner/name" for GitHub Enterprise Server instances and plain "owner/name" for github.com. This is the format that the gh CLI's --repo flag requires for GHE.
func HostPrefixedSlugForHost ¶
HostPrefixedSlugForHost is HostPrefixedSlug using an already-resolved host. This lets callers honor SSH HostName aliases without rewriting the remote.
func RepoSlug ¶
RepoSlug extracts the "owner/name" identifier from a GitHub remote or PR URL. It supports https URLs, scp-style ssh URLs (git@github.com:owner/name.git), ssh:// URLs, and longer paths such as PR links (the leading two path segments are used). It returns "" when the input has no owner/name pair.
Types ¶
type CmdFactory ¶
CmdFactory builds an exec.Cmd in the caller's workdir with the caller's env.
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host talks to GitHub through the gh CLI.
func New ¶
func New(cmd CmdFactory, cliAvailable func() bool, host, repo string) *Host
New builds a Host. cliAvailable reports whether the gh binary is resolvable on the caller's PATH (possibly overridden by env). host is the repo's GitHub hostname; when set the availability check is scoped to it via --hostname so a stale credential for an unrelated configured gh host cannot make this repo look unauthenticated. repo is the "owner/name" slug; when set it is passed via --repo to every PR/run command so they resolve the right repository regardless of the process working directory. The daemon runs from a fixed, non-repo working dir, so without this gh cannot infer the repo (or branch) and fails on every poll. host is optional; empty reproduces the legacy unscoped auth-check behavior.
func NewWithFork ¶
func NewWithFork(cmd CmdFactory, cliAvailable func() bool, host, repo, forkRepo string) *Host
NewWithFork builds a Host that opens PRs on repo using forkRepo as the head repository owner. forkRepo is an "owner/name" slug; only the owner is needed because gh pr create expects --head <owner>:<branch>. host is optional; see New for its role in scoping the auth check.
func (*Host) Capabilities ¶
func (h *Host) Capabilities() scm.Capabilities
func (*Host) FetchFailedCheckLogs ¶
func (*Host) FindAttestationPublicationIdentity ¶
func (*Host) GetCheckAttemptIdentity ¶
func (*Host) GetMergeableState ¶
func (*Host) GetPRState ¶
func (*Host) RerunCheck ¶
RerunCheck re-runs the Actions job behind check for the same commit, so a check the provider cancelled rather than failed can be retried without a new push. The job is identified from the check's details link, which is the only run/job identity `gh pr checks` reports: a link naming a job re-runs just that job (and its dependencies), and a link naming only a run re-runs that run's failed jobs. Anything else - a third-party status pointing at an external dashboard, or a run path this backend cannot read - names no re-runnable job, and the error says so rather than falling back to a wider rerun.