github

package
v0.156.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package github provides typed GitHub REST and GraphQL access via the go-gh library. Credentials resolve through go-gh's auth chain (GH_TOKEN/GITHUB_TOKEN, hosts.yml, then the gh binary's keyring); no gh CLI stdout is ever parsed.

Index

Constants

View Source
const EnvGitHubAPIBase = "AGENTICO_GITHUB_API_BASE"

EnvGitHubAPIBase is the environment variable that, when set, routes every GitHub API request to the given base URL with a dummy token, bypassing credential resolution. This is the seam packaged e2e journeys use to serve fixture responses from a local HTTP server without needing real gh credentials or a gh binary on PATH.

Variables

This section is empty.

Functions

func OverrideForTest

func OverrideForTest(baseURL, token string) (restore func())

OverrideForTest routes every subsequent client at the given base URL with the given token, bypassing credential resolution and the cache. The returned func undoes the override.

Types

type Client

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

Client bundles the REST and GraphQL clients for one GitHub host.

func ForHost

func ForHost(host string) (*Client, error)

ForHost returns a client for the given GitHub host ("" means github.com). Clients are cached per host.

func (*Client) ClosePR

func (c *Client) ClosePR(owner, repo string, number int) error

ClosePR closes a PR without merging.

func (*Client) CreateIssueComment

func (c *Client) CreateIssueComment(owner, repo string, number int, body string) error

CreateIssueComment posts a top-level conversation comment on a PR.

func (*Client) CreatePR

func (c *Client) CreatePR(p CreatePRParams) (string, error)

CreatePR opens a pull request and returns its URL. An empty Base targets the repository's default branch. If GitHub answers 422 with "already exists", the existing open PR's URL is returned instead (the branch push that preceded the call already updated it).

func (*Client) GetPR

func (c *Client) GetPR(owner, repo string, number int) (PRInfo, error)

GetPR returns body, base branch, canonical URL, and open/closed/merged state of a PR.

func (*Client) ListIssueComments

func (c *Client) ListIssueComments(owner, repo string, number int) ([]PRComment, error)

ListIssueComments returns all conversation comments on a PR.

func (*Client) ListPRReviewComments

func (c *Client) ListPRReviewComments(owner, repo string, number int) ([]PRComment, error)

ListPRReviewComments returns all inline review comments on a PR.

func (*Client) ListPRReviews

func (c *Client) ListPRReviews(owner, repo string, number int) ([]PRReview, error)

ListPRReviews returns all submitted reviews on a PR.

func (*Client) ReplyToReviewComment

func (c *Client) ReplyToReviewComment(owner, repo string, number, commentID int, body string) error

ReplyToReviewComment replies in-thread to an inline review comment.

func (*Client) ResolveReviewThread

func (c *Client) ResolveReviewThread(threadNodeID string) error

ResolveReviewThread marks one review thread resolved.

func (*Client) ReviewThreadMap

func (c *Client) ReviewThreadMap(owner, repo string, number int) (map[int]string, error)

ReviewThreadMap returns comment-database-ID → thread node ID for every unresolved review thread on a PR (first 100 threads).

func (*Client) UpdatePRBody

func (c *Client) UpdatePRBody(owner, repo string, number int, body string) error

UpdatePRBody replaces a PR's description.

type CreatePRParams

type CreatePRParams struct {
	Owner, Repo, Head, Base, Title, Body string
	Draft                                bool
}

CreatePRParams describes a pull request to open.

type NoCredentialsError

type NoCredentialsError struct{ Host string }

NoCredentialsError reports that no token could be resolved for a host.

func (*NoCredentialsError) Error

func (e *NoCredentialsError) Error() string

type PRComment

type PRComment struct {
	ID   int    `json:"id"`
	Path string `json:"path"`
	Line int    `json:"line"`
	Body string `json:"body"`
	User struct {
		Login string `json:"login"`
	} `json:"user"`
	CreatedAt string `json:"created_at"`
	DiffHunk  string `json:"diff_hunk"`
	InReplyTo int    `json:"in_reply_to_id"`
}

PRComment is one inline review comment or issue comment as returned by the GitHub REST API (subset of fields the orchestrator consumes).

type PRInfo

type PRInfo struct {
	Body    string
	BaseRef string
	URL     string
	// State is GitHub's "open" or "closed". A merged PR reports "closed", so
	// Merged is what distinguishes the two terminal outcomes.
	State  string
	Merged bool
}

PRInfo is the subset of pull-request details the orchestrator consumes.

type PRReview

type PRReview struct {
	ID   int    `json:"id"`
	Body string `json:"body"`
	User struct {
		Login string `json:"login"`
	} `json:"user"`
	SubmittedAt string `json:"submitted_at"`
}

PRReview is a submitted PR review (its top-level body, not inline comments).

Jump to

Keyboard shortcuts

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