github

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentUser

func GetCurrentUser(ctx context.Context) (string, error)

GetCurrentUser returns the authenticated GitHub user's login.

func RepoFullName

func RepoFullName(cfg *config.Config, short string) string

RepoFullName maps short repo name to full GitHub path using config.

func RepoShortName

func RepoShortName(cfg *config.Config, full string) string

RepoShortName maps full GitHub path to short repo name using config.

Types

type ApprovedPR

type ApprovedPR struct {
	Number         int        `json:"number"`
	Title          string     `json:"title"`
	Author         AuthorInfo `json:"author"`
	Repository     RepoInfo   `json:"repository"`
	CreatedAt      string     `json:"createdAt"`
	URL            string     `json:"url"`
	ReviewDecision string     `json:"reviewDecision"`
}

ApprovedPR represents a user's approved but unmerged PR.

func GetApprovedUnmerged

func GetApprovedUnmerged(ctx context.Context, repoFilter string) ([]ApprovedPR, error)

GetApprovedUnmerged fetches the user's own PRs that are approved but not yet merged.

type AuthorInfo

type AuthorInfo struct {
	Login string `json:"login"`
}

AuthorInfo holds author login info.

type Client

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

Client wraps go-github with auth from `gh auth token`.

func NewClient

func NewClient(ctx context.Context) (*Client, error)

NewClient creates a GitHub client using the token from `gh auth token`.

func (*Client) GetPRAuthor

func (c *Client) GetPRAuthor(ctx context.Context, fullRepo string, prNumber int) (string, error)

GetPRAuthor returns the login of the PR author.

func (*Client) GetPRDetails

func (c *Client) GetPRDetails(ctx context.Context, fullRepo string, prNumber int) (*PRDetails, error)

GetPRDetails fetches details for a specific PR.

func (*Client) GetPRFiles

func (c *Client) GetPRFiles(ctx context.Context, fullRepo string, prNumber int) ([]string, error)

GetPRFiles returns the list of changed file paths for a PR.

func (*Client) GetPRState

func (c *Client) GetPRState(ctx context.Context, fullRepo string, prNumber int) (string, error)

GetPRState returns the state of a PR: OPEN, CLOSED, or MERGED.

func (*Client) GetPRStateByBranch

func (c *Client) GetPRStateByBranch(ctx context.Context, fullRepo, branch string) (string, int, error)

GetPRStateByBranch looks up PRs by head branch name and returns the state ("MERGED", "CLOSED", "OPEN") and PR number of the first match. Returns ("", 0, nil) if no PR found for that branch.

func (*Client) GetPRTitle

func (c *Client) GetPRTitle(ctx context.Context, fullRepo string, prNumber int) (string, error)

GetPRTitle returns the title of a PR.

func (*Client) GetReviewStatus

func (c *Client) GetReviewStatus(ctx context.Context, fullRepo string, prNumber int) (string, error)

GetReviewStatus returns the user's latest review state on a PR.

func (*Client) GitHub

func (c *Client) GitHub() *gh.Client

GitHub returns the underlying go-github client.

type PRDetails

type PRDetails struct {
	Number      int    `json:"number"`
	Title       string `json:"title"`
	Author      string `json:"author"`
	State       string `json:"state"`
	HeadRefName string `json:"head_ref_name"`
	BaseRefName string `json:"base_ref_name"`
	Body        string `json:"body"`
	CreatedAt   string `json:"created_at"`
	URL         string `json:"url"`
	IsFork      bool   `json:"is_fork"`
}

PRDetails holds basic PR information.

type RepoInfo

type RepoInfo struct {
	Name          string `json:"name"`
	NameWithOwner string `json:"nameWithOwner"`
}

RepoInfo holds repository identification.

type ReviewRequest

type ReviewRequest struct {
	Number     int        `json:"number"`
	Title      string     `json:"title"`
	Author     AuthorInfo `json:"author"`
	Repository RepoInfo   `json:"repository"`
	CreatedAt  string     `json:"createdAt"`
	URL        string     `json:"url"`
}

ReviewRequest represents a PR review request.

func GetReviewRequests

func GetReviewRequests(ctx context.Context, repoFilter string) ([]ReviewRequest, error)

GetReviewRequests fetches PRs where the user is a requested reviewer, including re-reviews. Uses GraphQL via `gh api graphql`.

func ListOpenPRs

func ListOpenPRs(ctx context.Context, fullRepo string, limit int) ([]ReviewRequest, error)

ListOpenPRs lists open PRs for a repository using `gh pr list`.

Jump to

Keyboard shortcuts

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