github

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDiffComment

func BuildDiffComment(codeDiff, repoName, baseBranch, oldCommit, newCommit string) string

BuildDiffComment generates a PR comment with interdiff output, using collapsible sections for each file.

func BuildStackBlock

func BuildStackBlock(prNumbers []int, current int) string

BuildStackBlock generates a markdown stack navigation block showing the current PR's position in the stack.

func BuildStackedPRBody

func BuildStackedPRBody(commitHash, repoFullName string, prNumber int, allPRs []int, commitBody string) string

BuildStackedPRBody generates the full PR body for a stacked PR. For a single PR (len(allPRs) <= 1), only the commitBody is returned.

func ParseRepoFromURL

func ParseRepoFromURL(url string) (owner, repo string, err error)

ParseRepoFromURL extracts owner and repo name from a GitHub remote URL. Supports both HTTPS and SSH formats.

Types

type Client

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

Client wraps go-github for PR mutations and GraphQL queries.

func NewClient

func NewClient(token, remoteURL, apiURL string) (*Client, error)

NewClient creates a GitHub client for the given repository. remoteURL is the git remote URL (e.g. https://github.com/owner/repo.git), from which owner and repo are parsed. If apiURL is non-empty, it is used as the GitHub API base URL (for GitHub Enterprise or testing).

func (*Client) CommentOnPR

func (c *Client) CommentOnPR(number int, body string) error

CommentOnPR posts a comment on a pull request.

func (*Client) CreatePR

func (c *Client) CreatePR(head, base, title, body string, draft bool) (*PRInfo, error)

CreatePR creates a new pull request and returns its info.

func (*Client) GetAuthenticatedUser

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

GetAuthenticatedUser returns the login of the authenticated user.

func (*Client) LookupPRsByBranch

func (c *Client) LookupPRsByBranch(branches []string) (map[string]*PRInfo, error)

LookupPRsByBranch queries GitHub's GraphQL API for open PRs matching the given head branch names. Returns a map from branch name to PRInfo for branches that have an open PR.

func (*Client) Owner

func (c *Client) Owner() string

Owner returns the repository owner.

func (*Client) Repo

func (c *Client) Repo() string

Repo returns the repository name.

func (*Client) RequestReviewers

func (c *Client) RequestReviewers(number int, reviewers []string) error

RequestReviewers adds reviewers to a pull request.

func (*Client) UpdatePR

func (c *Client) UpdatePR(number int, opts UpdatePROpts) error

UpdatePR updates fields on an existing pull request.

type PRInfo

type PRInfo struct {
	Number      int    `json:"number"`
	State       string `json:"state"`
	URL         string `json:"url"`
	Title       string `json:"title"`
	Body        string `json:"body"`
	HeadRefName string `json:"headRefName"`
	BaseRefName string `json:"baseRefName"`
	IsDraft     bool   `json:"isDraft"`
}

PRInfo holds the essential fields of a pull request.

type Service

type Service interface {
	CreatePR(head, base, title, body string, draft bool) (*PRInfo, error)
	UpdatePR(number int, opts UpdatePROpts) error
	CommentOnPR(number int, body string) error
	GetAuthenticatedUser() (string, error)
	RequestReviewers(number int, reviewers []string) error
	LookupPRsByBranch(branches []string) (map[string]*PRInfo, error)
	Owner() string
	Repo() string
}

Service defines the GitHub operations needed by the send pipeline.

type UpdatePROpts

type UpdatePROpts struct {
	Title *string
	Body  *string
	Base  *string
	Draft *bool
}

UpdatePROpts contains optional fields for updating a PR.

Jump to

Keyboard shortcuts

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