Documentation
¶
Index ¶
- Constants
- func GetCurrentUser(ctx context.Context) (string, error)
- func IsNotFound(err error) bool
- func RepoFullName(cfg *config.Config, short string) string
- func RepoShortName(cfg *config.Config, full string) string
- type ApprovedPR
- type AuthorInfo
- type Client
- func (c *Client) GetPRAuthor(ctx context.Context, fullRepo string, prNumber int) (string, error)
- func (c *Client) GetPRDetails(ctx context.Context, fullRepo string, prNumber int) (*PRDetails, error)
- func (c *Client) GetPRFiles(ctx context.Context, fullRepo string, prNumber int) ([]string, error)
- func (c *Client) GetPRState(ctx context.Context, fullRepo string, prNumber int) (string, error)
- func (c *Client) GetPRStateByBranch(ctx context.Context, fullRepo, branch string) (string, int, error)
- func (c *Client) GetPRTitle(ctx context.Context, fullRepo string, prNumber int) (string, error)
- func (c *Client) GetReviewStatus(ctx context.Context, fullRepo string, prNumber int) (string, error)
- func (c *Client) GitHub() *gh.Client
- func (c *Client) IsRequestedReviewer(ctx context.Context, fullRepo string, prNumber int, login string) (bool, error)
- type MyPR
- type PRDetails
- type RepoInfo
- type ReviewRequest
- func GetReviewRequests(ctx context.Context, repoFilter string, ignoreDrafts bool) ([]ReviewRequest, error)
- func GetReviewRequestsForRepos(ctx context.Context, repoFullNames []string, ignoreDrafts bool) ([]ReviewRequest, error)
- func ListOpenPRs(ctx context.Context, fullRepo string, limit int, ignoreDrafts bool) ([]ReviewRequest, error)
Constants ¶
const ( ReviewKindNew = "new" ReviewKindRereview = "rereview" )
Review request kinds, set on ReviewRequest.Kind by GetReviewRequests.
Variables ¶
This section is empty.
Functions ¶
func GetCurrentUser ¶
GetCurrentUser returns the authenticated GitHub user's login.
func IsNotFound ¶ added in v0.12.0
IsNotFound reports whether err is a GitHub 404 (deleted PR or repo).
func RepoFullName ¶
RepoFullName maps short repo name to full GitHub path 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, ignoreDrafts bool) ([]ApprovedPR, error)
GetApprovedUnmerged fetches the user's own PRs that are approved but not yet merged. When ignoreDrafts is true, draft PRs are excluded at the GitHub search layer.
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 (*Client) GetPRAuthor ¶
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 ¶
GetPRFiles returns the list of changed file paths for a PR.
func (*Client) GetPRState ¶
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 ¶
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.
type MyPR ¶ added in v0.11.0
type MyPR struct {
Number int `json:"number"`
Title string `json:"title"`
Repository RepoInfo `json:"repository"`
CreatedAt string `json:"createdAt"`
URL string `json:"url"`
IsDraft bool `json:"isDraft"`
ReviewDecision string `json:"reviewDecision"`
Mergeable string `json:"mergeable"`
// BaseRefName and HeadRefName let callers detect stacked PRs: PR A
// depends on PR B when A's BaseRefName equals B's HeadRefName.
BaseRefName string `json:"baseRefName"`
HeadRefName string `json:"headRefName"`
ReviewRequests struct {
TotalCount int `json:"totalCount"`
} `json:"reviewRequests"`
Commits struct {
Nodes []struct {
Commit struct {
StatusCheckRollup struct {
State string `json:"state"`
} `json:"statusCheckRollup"`
} `json:"commit"`
} `json:"nodes"`
} `json:"commits"`
}
MyPR represents one of the current user's open pull requests, enriched with review and CI status for `zen board`'s status classification.
func GetMyOpenPRs ¶ added in v0.11.0
GetMyOpenPRs fetches the user's own open PRs, enriched with draft state, review decision, mergeability, pending review requests, and the latest commit's CI check rollup — enough to classify each into a status bucket (ready to merge, failing CI, changes requested, in review, in flight, draft).
func (MyPR) CheckState ¶ added in v0.11.0
CheckState returns the latest commit's CI status-check rollup state (e.g. "SUCCESS", "FAILURE", "PENDING"), or "" if no checks are reported.
func (MyPR) HasReviewRequests ¶ added in v0.11.0
HasReviewRequests reports whether any reviewers are currently requested.
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"`
HeadSHA string `json:"head_sha"`
BaseRefName string `json:"base_ref_name"`
Body string `json:"body"`
CreatedAt string `json:"created_at"`
URL string `json:"url"`
IsFork bool `json:"is_fork"`
Draft bool `json:"draft"`
}
PRDetails holds basic PR information.
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"`
HeadRefOid string `json:"headRefOid"`
IsDraft bool `json:"isDraft"`
Closed bool `json:"closed"`
// Kind is "new" or "rereview", set by GetReviewRequests to record which
// of its two queries matched. Not part of the GitHub API response.
Kind string `json:"-"`
}
ReviewRequest represents a PR review request.
func GetReviewRequests ¶
func GetReviewRequests(ctx context.Context, repoFilter string, ignoreDrafts bool) ([]ReviewRequest, error)
GetReviewRequests fetches PRs where the user is a requested reviewer, including re-reviews. Uses GraphQL via `gh api graphql`. When ignoreDrafts is true, draft PRs are filtered out at the GitHub search layer. An empty repoFilter searches every repository the user can see, which is only safe for callers that show what they get; the daemon uses GetReviewRequestsForRepos instead.
func GetReviewRequestsForRepos ¶ added in v0.12.0
func GetReviewRequestsForRepos(ctx context.Context, repoFullNames []string, ignoreDrafts bool) ([]ReviewRequest, error)
GetReviewRequestsForRepos searches each configured repository separately and merges the results. One global search cannot serve the daemon: its page is filled on GitHub's terms, so requests in unconfigured repositories can crowd out a configured repository's PR. Scoping per repository also keeps every query well under GitHub's 256-character search limit, which a combined `repo:a repo:b ...` query would eventually cross.
A repository that fails is reported but does not hide the others: the returned slice holds every repository that answered, alongside the error.
func ListOpenPRs ¶
func ListOpenPRs(ctx context.Context, fullRepo string, limit int, ignoreDrafts bool) ([]ReviewRequest, error)
ListOpenPRs lists open PRs for a repository using `gh pr list`. When ignoreDrafts is true, drafts are excluded via `--draft=false`.